Monday, 27 May 2013

Apache X-Forward-For settings for behinding reverse proxy

Add following settings into your httpd.conf or the configuration file in sites-available that linked to sites-enabled.
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" proxy 
SetEnvIf X-Forwarded-For "^.*\..*\..*\..*" forwarded 
CustomLog "logs/access_log" combined env=!forwarded
CustomLog "logs/access_log" proxy env=forwarded
After saving the settings, restart your httpd and you should see the real client IP in access log.

No comments:

Post a Comment