add req.http.x-forwarded-for header

Andreas Götzfried revirii at
Thu Feb 7 09:03:44 CET 2013

Good Morning,

> I think varnishncsa reads the information in the shared memory log
> *before* your modification in the VCL. I can't test right now but if
> you follow both varnishlog and varnishncsa you might understand what
> happens.

Hm, but then the wished manipulation within vcl_recv (setting
x-forwarded-for and writing it into varnish log instead of client.ip)
won't work at all, as the logs are written before vcl_recv. Well, why
should it work, as varnishncsa reads the shared memory and writes the
log, and varnish itself reads shared memory and then starts with

Changing the parameters of the log daemon won't help either, as an
external request doesn't set x-forwarded-for-

> I have no idea if it would actually work but you could try to issue a
> restart to see whether it affects varnishncsa.
> if (!req.http.X-Forwarded-For) {
>     set req.http.X-Forwarded-For = client.ip;
>     return(restart);
> }

Message from VCC-compiler:
Invalid return "restart"
('input' Line 97 Pos 24)
-----------------------#######-- subroutine "vcl_recv"
('input' Line 77 Pos 5)
sub vcl_recv {

...which is the "vcl_recv" method
Legal returns are: "error" "lookup" "pass" "pipe"

Seems illegal ;-)


More information about the varnish-misc mailing list