add req.http.x-forwarded-for header

Dridi Boukelmoune dridi.boukelmoune at zenika.com
Wed Feb 13 22:32:47 CET 2013


Hi,

Try this vmod instead: https://github.com/dridi/libvmod-logger

Best Regards,
Dridi

On Thu, Feb 7, 2013 at 9:03 AM, Andreas Götzfried
<revirii at googlemail.com> wrote:
> 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
> vcl_recv.
>
> https://www.varnish-cache.org/docs/trunk/reference/varnishncsa.html
>
> 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)
>                 return(restart);
> -----------------------#######--
>
> ...in 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 ;-)
>
>
> thx
> Andreas
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc



More information about the varnish-misc mailing list