Conditional logging of X-Fowarded-For in varnishncsa

Rowan @ Jetboy rowan at
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 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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the varnish-misc mailing list