Skip to content

Instantly share code, notes, and snippets.

@williameliel
Created March 22, 2016 16:01
Show Gist options
  • Save williameliel/ce5131182f7c3b9d918a to your computer and use it in GitHub Desktop.
Save williameliel/ce5131182f7c3b9d918a to your computer and use it in GitHub Desktop.
Add IP to apache log -varnish
default_vcl add to vcl_recv func
if (req.restarts == 0) {
if (req.http.X-Forwarded-For) {
set req.http.X-Forwarded-For = req.http.X-Forwarded-For + ", " + client.ip;
} else {
set req.http.X-Forwarded-For = client.ip;
}
}
Add this to httpd or apache2 conf
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" varnishcombined
Add this to vhost
CustomLog /var/log/httpd/www.abc.com/access.log varnishcombined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment