Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save christopher-b/7cf281a186b94ded0f91277afe13dc1c to your computer and use it in GitHub Desktop.
Save christopher-b/7cf281a186b94ded0f91277afe13dc1c to your computer and use it in GitHub Desktop.
Apache - log real IP for proxied requests
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
# From http://www.techstacks.com/howto/log-client-ip-and-xforwardedfor-ip-in-apache.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment