Skip to content

Instantly share code, notes, and snippets.

@robhoare
Last active August 29, 2015 14:26
Show Gist options
  • Select an option

  • Save robhoare/821a635fb4ba721c3b4d to your computer and use it in GitHub Desktop.

Select an option

Save robhoare/821a635fb4ba721c3b4d to your computer and use it in GitHub Desktop.
Apache: Log IP correctly when using a CDN

#Apache: Log IP correctly when using a CDN

(assumes Ubuntu)

##Edit Config

in /etc/apache2/apache2.conf

after HostnameLookups Off add

RemoteIPHeader X-Forwarded-For
RemoteIPInternalProxy 127.0.0.1/8

in the LogFormat line,

LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined

change %h to %a

##Enable Module

Then enable mod_remoteip:

a2enmod remoteip

restart Apache

service apache2 restart

IP of remote device should now be logged correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment