Tip of the day: Log tweek for Apache+Squid
Submitted by marineam on Wed, 10/15/2008 - 05:21
I recently reconfigured my server to run Squid in front of Apache in hopes that it will hold up under load a little better now (Polvi's site is just too damn popular with web crawlers). To keep people who like reading their Apache logs happy I wanted to make Apache log the original client instead of 127.0.0.1. Here's the best I've come up with so far:
# Set using the normal REMOTE_ADDR value first
SetEnvIf Remote_Addr "(.*)" TRUE_REMOTE_ADDR=$1
# Pick the last ip address off the proxy list if we can
SetEnvIf X-Forwarded-For "([0-9\.]+)$" TRUE_REMOTE_ADDR=$1
LogFormat "%{TRUE_REMOTE_ADDR}e %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
Seems to be working so far :-)
- Log in to post comments