Apache Configuration – logging traffic from X-Forwarded-For header

This case will help you to log to apache server any traffic coming from the load balancer, proxy or any IDS.

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 ${APACHE_LOG_DIR}/access_log combined env=!forwarded
CustomLog ${APACHE_LOG_DIR}/access_log proxy env=forwarded

Majd Arbash

...

Leave a Reply