Skip to content

Instantly share code, notes, and snippets.

@alvarow
Created February 9, 2017 17:48
Show Gist options
  • Save alvarow/b59eb178127c2aa416987a64db1a530e to your computer and use it in GitHub Desktop.
Save alvarow/b59eb178127c2aa416987a64db1a530e to your computer and use it in GitHub Desktop.
Sets Apache Log of the X-Forwarded-For client IP address or the real client ip address if the X-Forwarded-For header does not exist.
# Log the X-Forwarded-For client IP address or the real client ip address if the X-Forwarded-For header does not exist.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment