<div dir="ltr">Hey Nicolas,<div><br></div><div>This is done before vcl_recv is called in varnishd code:</div><div><br></div><div><a href="https://github.com/varnishcache/varnish-cache/blob/varnish-4.0.0/bin/varnishd/cache/cache_req_fsm.c#L719-L728">https://github.com/varnishcache/varnish-cache/blob/varnish-4.0.0/bin/varnishd/cache/cache_req_fsm.c#L719-L728</a><br></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">--<br>Reza Naghibi<br>Varnish Software</div></div></div>
<br><div class="gmail_quote">On Thu, Feb 16, 2017 at 4:42 PM, Nicolas Delmas <span dir="ltr"><<a href="mailto:colas.delmas@gmail.com" target="_blank">colas.delmas@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto">Hello, <div dir="auto"><br></div><div dir="auto">Why is this part if code useless ? </div><div dir="auto">Is that because this code is in the builtin.vcl ?</div><div dir="auto"><br></div><div dir="auto">Thanks</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">Le 14 févr. 2017 10:10 AM, "Guillaume Quintard" <<a href="mailto:guillaume@varnish-software.com" target="_blank">guillaume@varnish-software.<wbr>com</a>> a écrit :<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>The snippet is legacy code for v3, and it's now useless/counter-productive in v4.</div></div><div class="gmail_extra"><br clear="all"><div><div class="m_885002540370018349m_1230026204366212524gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>-- <br></div>Guillaume Quintard<br></div></div></div>
<br><div class="gmail_quote">On Tue, Feb 14, 2017 at 9:20 AM, Donath, Niklas <span dir="ltr"><<a href="mailto:Niklas.Donath@lvdigital.de" target="_blank">Niklas.Donath@lvdigital.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="white" lang="DE" link="#0563C1" vlink="#954F72">
<div class="m_885002540370018349m_1230026204366212524m_-748305146233834759WordSection1">
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">Hi there,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">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:<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">in the official doc, it says that x-forwarded-for is automatically set, like it is obvious in the source code:
<a href="https://github.com/varnishcache/varnish-cache/blob/4.0/bin/varnishd/cache/cache_req_fsm.c#L724" target="_blank">
https://github.com/varnishcach<wbr>e/varnish-cache/blob/4.0/bin/v<wbr>arnishd/cache/cache_req_fsm.c#<wbr>L724</a><u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">But a lot of people are adding a snippet for vcl_recv like<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">if (req.restarts == 0) {<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt"> if (req.http.X-Forwarded-For) {<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt"> set req.http.X-Forwarded-For = req.http.X-Forwarded-For + ", " + client.ip;<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt"> } else {<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt"> set req.http.X-Forwarded-For = client.ip;<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt"> </span><span style="font-size:11.0pt">}<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">}<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">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.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">Thank you very much!<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">Greetings, Niklas<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt"><u></u> <u></u></span></p>
</div>
</div>
<br>______________________________<wbr>_________________<br>
varnish-misc mailing list<br>
<a href="mailto:varnish-misc@varnish-cache.org" target="_blank">varnish-misc@varnish-cache.org</a><br>
<a href="https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc" rel="noreferrer" target="_blank">https://www.varnish-cache.org/<wbr>lists/mailman/listinfo/varnish<wbr>-misc</a><br></blockquote></div><br></div>
<br>______________________________<wbr>_________________<br>
varnish-misc mailing list<br>
<a href="mailto:varnish-misc@varnish-cache.org" target="_blank">varnish-misc@varnish-cache.org</a><br>
<a href="https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc" rel="noreferrer" target="_blank">https://www.varnish-cache.org/<wbr>lists/mailman/listinfo/varnish<wbr>-misc</a><br></blockquote></div></div>
</div></div><br>______________________________<wbr>_________________<br>
varnish-misc mailing list<br>
<a href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-cache.org</a><br>
<a href="https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc" rel="noreferrer" target="_blank">https://www.varnish-cache.org/<wbr>lists/mailman/listinfo/<wbr>varnish-misc</a><br></blockquote></div><br></div>