Hey Nicolas,

This is done before vcl_recv is called in varnishd code:

https://github.com/varnishcache/varnish-cache/blob/varnish-4.0.0/bin/varnishd/cache/cache_req_fsm.c#L719-L728

--
Reza Naghibi
Varnish Software

On Thu, Feb 16, 2017 at 4:42 PM, Nicolas Delmas <[email protected]>
wrote:

> Hello,
>
> Why is this part if code useless ?
> Is that because this code is in the builtin.vcl ?
>
> Thanks
>
> Le 14 févr. 2017 10:10 AM, "Guillaume Quintard" <
> [email protected]> a écrit :
>
>> Hi,
>>
>> The snippet is legacy code for v3, and it's now
>> useless/counter-productive in v4.
>>
>> --
>> Guillaume Quintard
>>
>> On Tue, Feb 14, 2017 at 9:20 AM, Donath, Niklas <
>> [email protected]> wrote:
>>
>>> Hi there,
>>>
>>>
>>>
>>> actually, i am in a migration project from varnish 3 to varnish 4.0, and
>>> i was confused about the x-forwarded-for header settings in varnish 4.0:
>>>
>>> in the official doc, it says that x-forwarded-for is automatically set,
>>> like it is obvious in the source code: https://github.com/varnishcach
>>> e/varnish-cache/blob/4.0/bin/varnishd/cache/cache_req_fsm.c#L724
>>>
>>>
>>>
>>> But a lot of people are adding a snippet for vcl_recv like
>>>
>>>
>>>
>>> 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;
>>>
>>>     }
>>>
>>> }
>>>
>>>
>>>
>>> Which, from my point of view, is the same implementation as it already
>>> should exist as the docs say. I currently do not have a LB/proxy
>>> infrastructure to test it, so maybe someone can clear this up, if
>>> x-forwarded-for is automatically set by varnish before executing the
>>> vcl_recv from my custom .vcl-file, or if the given snippet is required to
>>> set the real user ip for x-forwarded-for.
>>>
>>>
>>>
>>> Thank you very much!
>>>
>>>
>>>
>>> Greetings, Niklas
>>>
>>>
>>>
>>> _______________________________________________
>>> varnish-misc mailing list
>>> [email protected]
>>> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>>>
>>
>>
>> _______________________________________________
>> varnish-misc mailing list
>> [email protected]
>> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>>
>
> _______________________________________________
> varnish-misc mailing list
> [email protected]
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
_______________________________________________
varnish-misc mailing list
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc

Reply via email to