<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel>
        <title>haproxy -&amp;gt; varnish -&amp;gt; backend server</title>
        <description> Hi guys

Originally we had haproxy in front and connecting to backend server

   haproxy -&amp;gt; backend server

and applications and backend server see the real client ip fine without any issues

But we decided to try adding Varnish cache in between

   haproxy -&amp;gt; varnish -&amp;gt; backend server

Problem now is backend server and ips are seeing the client ip of the haproxy server and not real visitor client ips.

varnish has the appropriate forwarding of client ips, 

   remove req.http.X-Forwarded-For;
   set req.http.X-Forwarded-For = client.ip;

and works if Varnish only in front of backends.

So what setting if any in haproxy would I need to add or check for, to get the proper client ip from haproxy through varnish into the backend ?

Using haproxy v1.3 here with Varnish 3.0.2.

thanks</description>
        <link>http://www.serverphorums.com/read.php?10,508289,508289#msg-508289</link>
        <lastBuildDate>Thu, 23 May 2013 07:01:05 +0200</lastBuildDate>
        <generator>Phorum 5.2.18</generator>
        <item>
            <guid>http://www.serverphorums.com/read.php?10,508289,515997#msg-515997</guid>
            <title>Re: haproxy -&gt; varnish -&gt; backend server</title>
            <link>http://www.serverphorums.com/read.php?10,508289,515997#msg-515997</link>
            <description><![CDATA[ Just coming back to update you all on the solution. It was as David suggested just not letting varnish manipulate X-Forwarded-For, allowed haproxy -&gt; varnish configuration to work for the app :D<br />
<br />
Thanks for your help guys..]]></description>
            <dc:creator>p4guru</dc:creator>
            <category>HAProxy</category>
            <pubDate>Tue, 19 Jun 2012 19:11:58 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?10,508289,508373#msg-508373</guid>
            <title>Re: haproxy -&gt; varnish -&gt; backend server</title>
            <link>http://www.serverphorums.com/read.php?10,508289,508373#msg-508373</link>
            <description><![CDATA[ On Wed, Jun 6, 2012 at 3:50 AM, David Coulson &lt;david@davidcoulson.net&gt; wrote:<br />
&gt; you might also want to look at having varnish prepend the haproxy IP to the<br />
&gt; X-Forwarded-For line, rather than just pass it along - Most proxies seem to<br />
&gt; comma delimit a list of IPs of all the devices the request has passed<br />
&gt; through.<br />
&gt;<br />
&gt;<br />
<br />
Hey David,<br />
<br />
Having a &quot;single&quot; line with values separated by commas or having<br />
multiple lines, one per value are both ways allowed by RFC to write<br />
headers in HTTP.<br />
So any HTTP processing tool should make no difference whatever way<br />
headers are written.<br />
<br />
Saying that, it is usually recommended to chain proxies like this:<br />
Varnish -&gt; HAProxy -&gt; server.<br />
Now, if you can't and must let Varnish behind HAProxy, it should be<br />
not complicated to do the X-Forwarded-For clean up (untill Varnish can<br />
understand proxy-protocol).<br />
<br />
cheers]]></description>
            <dc:creator>Baptiste</dc:creator>
            <category>HAProxy</category>
            <pubDate>Wed, 06 Jun 2012 07:40:02 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?10,508289,508300#msg-508300</guid>
            <title>Re: haproxy -&gt; varnish -&gt; backend server</title>
            <link>http://www.serverphorums.com/read.php?10,508289,508300#msg-508300</link>
            <description><![CDATA[ you might also want to look at having varnish prepend the haproxy IP to <br />
the X-Forwarded-For line, rather than just pass it along - Most proxies <br />
seem to comma delimit a list of IPs of all the devices the request has <br />
passed through.<br />
<br />
On 6/5/12 9:46 PM, <a href="mailto:&#104;&#97;&#112;&#114;&#111;&#120;&#121;&#64;&#115;&#101;&#114;&#118;&#101;&#114;&#112;&#104;&#111;&#114;&#117;&#109;&#115;&#46;&#99;&#111;&#109;">&#104;&#97;&#112;&#114;&#111;&#120;&#121;&#64;&#115;&#101;&#114;&#118;&#101;&#114;&#112;&#104;&#111;&#114;&#117;&#109;&#115;&#46;&#99;&#111;&#109;</a> wrote:<br />
&gt; Thanks David, your suggestion helped move me closer to solution, just have to confirm whether it's working completely as some visitors still show haproxy ip within the app itself on backend, but not sure if that is a cached value by the app.<br />
&gt;<br />
&gt; Sebastien, yeah normally that would be what I'd do, just haproxy is a managed service so I have no direct control over it only from varnish downwards.<br />
&gt;<br />
&gt; ---<br />
&gt; posted at <a href="http://www.serverphorums.com" target="_blank"  rel="nofollow">http://www.serverphorums.com</a><br />
&gt; <a href="http://www.serverphorums.com/read.php?10,508289,508298#msg-508298" target="_blank"  rel="nofollow">http://www.serverphorums.com/read.php?10,508289,508298#msg-508298</a><br />
&gt;]]></description>
            <dc:creator>David Coulson</dc:creator>
            <category>HAProxy</category>
            <pubDate>Wed, 06 Jun 2012 04:00:01 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?10,508289,508298#msg-508298</guid>
            <title>Re: haproxy -&gt; varnish -&gt; backend server</title>
            <link>http://www.serverphorums.com/read.php?10,508289,508298#msg-508298</link>
            <description><![CDATA[ Thanks David, your suggestion helped move me closer to solution, just have to confirm whether it's working completely as some visitors still show haproxy ip within the app itself on backend, but not sure if that is a cached value by the app.<br />
<br />
Sebastien, yeah normally that would be what I'd do, just haproxy is a managed service so I have no direct control over it only from varnish downwards.]]></description>
            <dc:creator>p4guru</dc:creator>
            <category>HAProxy</category>
            <pubDate>Wed, 06 Jun 2012 03:46:42 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?10,508289,508295#msg-508295</guid>
            <title>Re: haproxy -&gt; varnish -&gt; backend server</title>
            <link>http://www.serverphorums.com/read.php?10,508289,508295#msg-508295</link>
            <description><![CDATA[ why not put varnish in front of haproxy like this:<br />
haproxy listen on ip public 1 and localhost<br />
varnish listen on ip public 2 and forward to localhost<br />
<br />
so cached traffic is immediately served by varnish without hitting haproxy.<br />
<br />
and when you don t need to cache the traffic you use ip public 1 (haproxy)<br />
<br />
in our setup the varnish ip is s.mydomain.com serving image/css/js<br />
and haproxy is www.mydomain.com serving dynamic content containing urls in s..mydomain.com.<br />
<br />
as a bonus no cookie is sent to s.mydomain.com<br />
<br />
--<br />
Sebastien E.<br />
<br />
<br />
Le 5 juin 2012 à 21:06, David Coulson &lt;david@davidcoulson.net&gt; a écrit :<br />
<br />
&gt; Is haproxy adding X-Forwarded-For to the request it sends varnish? If so, just don't have varnish manipulate X-Forwarded-For and your app will use the header added by HAProxy.<br />
&gt; <br />
&gt; David<br />
&gt; <br />
&gt; On 6/5/12 9:04 PM, <a href="mailto:&#104;&#97;&#112;&#114;&#111;&#120;&#121;&#64;&#115;&#101;&#114;&#118;&#101;&#114;&#112;&#104;&#111;&#114;&#117;&#109;&#115;&#46;&#99;&#111;&#109;">&#104;&#97;&#112;&#114;&#111;&#120;&#121;&#64;&#115;&#101;&#114;&#118;&#101;&#114;&#112;&#104;&#111;&#114;&#117;&#109;&#115;&#46;&#99;&#111;&#109;</a> wrote:<br />
&gt;&gt; Hi guys<br />
&gt;&gt; <br />
&gt;&gt; Originally we had haproxy in front and connecting to backend server<br />
&gt;&gt; <br />
&gt;&gt;    haproxy -&gt;  backend server<br />
&gt;&gt; <br />
&gt;&gt; and applications and backend server see the real client ip fine without any issues<br />
&gt;&gt; <br />
&gt;&gt; But we decided to try adding Varnish cache in between<br />
&gt;&gt; <br />
&gt;&gt;    haproxy -&gt;  varnish -&gt;  backend server<br />
&gt;&gt; <br />
&gt;&gt; Problem now is backend server and ips are seeing the client ip of the haproxy server and not real visitor client ips.<br />
&gt;&gt; <br />
&gt;&gt; varnish has the appropriate forwarding of client ips,<br />
&gt;&gt; <br />
&gt;&gt;    remove req.http.X-Forwarded-For;<br />
&gt;&gt;    set req.http.X-Forwarded-For = client.ip;<br />
&gt;&gt; <br />
&gt;&gt; and works if Varnish only in front of backends.<br />
&gt;&gt; <br />
&gt;&gt; So what setting if any in haproxy would I need to add or check for, to get the proper client ip from haproxy through varnish into the backend ?<br />
&gt;&gt; <br />
&gt;&gt; Using haproxy v1.3 here with Varnish 3.0.2.<br />
&gt;&gt; <br />
&gt;&gt; thanks<br />
&gt;&gt; <br />
&gt;&gt; ---<br />
&gt;&gt; posted at <a href="http://www.serverphorums.com" target="_blank"  rel="nofollow">http://www.serverphorums.com</a><br />
&gt;&gt; <a href="http://www.serverphorums.com/read.php?10,508289,508289#msg-508289" target="_blank"  rel="nofollow">http://www.serverphorums.com/read.php?10,508289,508289#msg-508289</a><br />
&gt;&gt; <br />
&gt;]]></description>
            <dc:creator>Sebastien Estienne</dc:creator>
            <category>HAProxy</category>
            <pubDate>Wed, 06 Jun 2012 03:30:01 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?10,508289,508290#msg-508290</guid>
            <title>Re: haproxy -&gt; varnish -&gt; backend server</title>
            <link>http://www.serverphorums.com/read.php?10,508289,508290#msg-508290</link>
            <description><![CDATA[ Is haproxy adding X-Forwarded-For to the request it sends varnish? If <br />
so, just don't have varnish manipulate X-Forwarded-For and your app will <br />
use the header added by HAProxy.<br />
<br />
David<br />
<br />
On 6/5/12 9:04 PM, <a href="mailto:&#104;&#97;&#112;&#114;&#111;&#120;&#121;&#64;&#115;&#101;&#114;&#118;&#101;&#114;&#112;&#104;&#111;&#114;&#117;&#109;&#115;&#46;&#99;&#111;&#109;">&#104;&#97;&#112;&#114;&#111;&#120;&#121;&#64;&#115;&#101;&#114;&#118;&#101;&#114;&#112;&#104;&#111;&#114;&#117;&#109;&#115;&#46;&#99;&#111;&#109;</a> wrote:<br />
&gt; Hi guys<br />
&gt;<br />
&gt; Originally we had haproxy in front and connecting to backend server<br />
&gt;<br />
&gt;     haproxy -&gt;  backend server<br />
&gt;<br />
&gt; and applications and backend server see the real client ip fine without any issues<br />
&gt;<br />
&gt; But we decided to try adding Varnish cache in between<br />
&gt;<br />
&gt;     haproxy -&gt;  varnish -&gt;  backend server<br />
&gt;<br />
&gt; Problem now is backend server and ips are seeing the client ip of the haproxy server and not real visitor client ips.<br />
&gt;<br />
&gt; varnish has the appropriate forwarding of client ips,<br />
&gt;<br />
&gt;     remove req.http.X-Forwarded-For;<br />
&gt;     set req.http.X-Forwarded-For = client.ip;<br />
&gt;<br />
&gt; and works if Varnish only in front of backends.<br />
&gt;<br />
&gt; So what setting if any in haproxy would I need to add or check for, to get the proper client ip from haproxy through varnish into the backend ?<br />
&gt;<br />
&gt; Using haproxy v1.3 here with Varnish 3.0.2.<br />
&gt;<br />
&gt; thanks<br />
&gt;<br />
&gt; ---<br />
&gt; posted at <a href="http://www.serverphorums.com" target="_blank"  rel="nofollow">http://www.serverphorums.com</a><br />
&gt; <a href="http://www.serverphorums.com/read.php?10,508289,508289#msg-508289" target="_blank"  rel="nofollow">http://www.serverphorums.com/read.php?10,508289,508289#msg-508289</a><br />
&gt;]]></description>
            <dc:creator>David Coulson</dc:creator>
            <category>HAProxy</category>
            <pubDate>Wed, 06 Jun 2012 03:10:01 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?10,508289,508289#msg-508289</guid>
            <title>haproxy -&gt; varnish -&gt; backend server</title>
            <link>http://www.serverphorums.com/read.php?10,508289,508289#msg-508289</link>
            <description><![CDATA[ Hi guys<br />
<br />
Originally we had haproxy in front and connecting to backend server<br />
<br />
   haproxy -&gt; backend server<br />
<br />
and applications and backend server see the real client ip fine without any issues<br />
<br />
But we decided to try adding Varnish cache in between<br />
<br />
   haproxy -&gt; varnish -&gt; backend server<br />
<br />
Problem now is backend server and ips are seeing the client ip of the haproxy server and not real visitor client ips.<br />
<br />
varnish has the appropriate forwarding of client ips, <br />
<br />
   remove req.http.X-Forwarded-For;<br />
   set req.http.X-Forwarded-For = client.ip;<br />
<br />
and works if Varnish only in front of backends.<br />
<br />
So what setting if any in haproxy would I need to add or check for, to get the proper client ip from haproxy through varnish into the backend ?<br />
<br />
Using haproxy v1.3 here with Varnish 3.0.2.<br />
<br />
thanks]]></description>
            <dc:creator>p4guru</dc:creator>
            <category>HAProxy</category>
            <pubDate>Wed, 06 Jun 2012 03:04:29 +0200</pubDate>
        </item>
    </channel>
</rss>
