Conditional logging of X-Fowarded-For in varnishncsa

Rowan @ Jetboy rowan at jetboy.co.uk
Fri Aug 10 15:01:06 CEST 2012


With the setup:

 

SSL traffic > nginx > Varnish (for load balancing) > Backend Apache

Non-SSL traffic > Varnish > Backend Apache

varnishncsa with a custom log format

 

For non-SSL traffic, the IP of the originating request gets logged by
varnishncsa as %h; for the SSL traffic it's 127.0.0.1. I can pass the IP
from nginx in the X-Forwarded-For header and pick it up in varnishncsa as
%{X-Forwarded-For}i. I'd like to log the contents of %{X-Forwarded-For}i if
it exists, *OR* %h if it doesn't. Seemingly, the -f command line argument
will enable this, but not with a custom format set with the -F flag. This
generates the warning "-f and -F can not be combined". Is there a way around
this?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20120810/38e320d9/attachment-0001.html>


More information about the varnish-misc mailing list