Varnish and Apache log files

If you use Varnish with an Apache server and analyze Apache log files (with AWstats or something else), you probably saw all requests were coming from 127.0.0.1 (or the IP address Varnish is on). You’ve probably forgotten to change the LogFormat you use.

Fortunately, Varnish adds an header on its request to Apache with the remote IP address in it. Just replace “%h” with “%{X-Forwarded-For}i” in the LogFormat and reload your server.

This entry was posted in Computer, Linux. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.