Using mod_remoteip
and modifying apache's log format, real client IP addresses can easily be captured
Enable and configure mod_remoteip
LoadModule remoteip_module modules/mod_remoteip.so
<IfModule mod_remoteip.c>
RemoteIPHeader X-Forwarded-For # YMMV for different load balancers
RemoteIPInternalProxy 127.0.0.1
</IfModule>
Modify log variables
Replace the remote hostname variable, %h
, with the client ip variable provided by mod_remoteip
, %a
Old
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
New
LogFormat "%a %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
For more logging variables see the docs Apache Module mod_log_config