If you want to log the actual client IP address, you need to extract the X-Forward-For header from the request and in order to do that, you need to make a tiny edit in your httpd.conf file.
- Go to
/etc/apache2/confor/etc/httpd/confand openhttpd.conffile. - Search for the string that starts with:
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined. - Modify the
%hto%{X-Forwarded-For}i. Now, it should look like this:LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined. - Test the config to ensure that there are no typos by typing:
apachectl configtest. - Save and restart the service by typing:
systemctl restart httpdorsystemctl restart apache2. - In your terminal, type
tail -f /var/log/httpd/access.logand you'll be seeing the client IP being logged in your logs.
Hope you found this tip useful!