I've configured Varnish 3 with Apache and it is running perfectly alright. However i'm unable to get the Client ip logged in Apache logs. I tried a few solutions googling around with no luck. Right now my Apache access log file is logging the server IP instead of client IP addresses.
Here are my configurations for your kind consideration:
Varnish VCL: (/etc/varnish/default.vlc): http://pastebin.com/PuBqZ6fx
/etc/httpd/conf/httpd.conf
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" varnishcombined
...... Other Stuff ..... ErrorLog logs/fr-error-log CustomLog logs/fr-custom-log varnishcombined ...... Other Stuff .....
Note: Varnish Version installed is varnish-3.0.2-1.el5.x86_64
Thanks. Raheel
I think you've had a working config in your pastebin example, this should actually do the trick:
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;
}
}
In your vcl_recv{}.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With