You are reading

Varnish Broke My Logs

Posted: June 7, 2009 | By: TJ | In Technology | One comment

After setting up Varnish as a reverse proxy, I was really impressed with the results. A few kinks came up however after I implemented Varnish with Lighttpd. One major problem was that all remote requests logged in my log files were from 127.0.0.1. This isn’t very helpful. One way around this is to define the accesslog.format in the lighttpd.conf file so that remote IP addresses are not shown as localhost. Here is the snip from my lighttpd.conf:

accesslog.format = "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b /\"%{Referer}i\" \"%{User-Agent}i\""

Before force reloading the new configuration, test it first by running:

$ lighttpd -t -f /etc/lighttpd/lighttpd.conf

If the syntax checks out, reload Lighttpd:

$ /etc/init.d/lighttpd force-reload

Now you can check your access logs and it should be showing the IP addresses correctly:

$ tail -f /var/log/lighttpd/access.log

Leave your comment



Copyright © 2010. All rights reserved.

This blog is powered by WordPress and proudly hosted by (mt) Media Temple.