To log the actual client IP address from the X-Forwarded-For header of a request using an Apache server, make the following changes to the apache httpd.conf file
- Log into the EC2 instance running apache httpd process.
- Navigate to /etc/httpd/conf or /opt/products/apache2/conf path and open the file httpd.conf.
- Search for the string: “LogFormat “%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined”
- Change the %h to %{X-Forwarded-For}i. The string now appears as “LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined”
- Save the httpd.conf file and restart httpd process (if running as service "sudo service httpd restart")
No comments:
Post a Comment