Log real client IP behind proxy

If you can only see a single private IP in the web server log then you you are behind a proxy, either nginx or our resolver.

To log the real client IP address in the Apache log you need to change the following entries in the httpd.log.

#LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
#LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{X-Real-IP}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%{X-Real-IP}i %l %u %t \"%r\" %>s %b" common


If you are using nginx then change the following lines in nginx.conf

# log_format main '$remote_addr - $remote_user [$time_local] "$request" '
log_format main '$http_x_real_ip - $remote_user [$time_local] "$request" '





Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request



Please sign in to leave a comment.