Re: How to check backend servers thru Haproxy?

From: Baptiste <bedis9#gmail.com>
Date: Sun, 29 May 2011 17:34:08 +0200


Hi Guillaume

The text after "cookie" keyword is the cookie value and there is no relation between the server name and the cookie value. You can put there whatever text you want. ie
  server srv1 1.1.1.1:80 cookie blahblahblah When browsing your website, if HAproxy decides to associate your browser to the srv1, then it will send you a cookie named SRV with the value "blahblahblah".

You can check this in your browser the cookies associtated to a webpage.

cheers

On Fri, May 27, 2011 at 2:27 PM, Guillaume Bourque <guillaume.bourque#gmail.com> wrote:
> Hi Willy,
> should those two lines
>        server srv1 1.1.1.1:80 cookie s1
>        server srv2 1.1.1.2:80 cookie s2
> be
>        server srv1 1.1.1.1:80 cookie srv1
>        server srv2 1.1.1.2:80 cookie srv2
> Not sure but since I can't test right now i thought to ask the master  ;-)
> thnaks
>
>
>> Yes you can do that using the "force-persist" statement. The principle
>> is that you define with ACLs how to detect that an incoming request is
>> in fact one of your tests. That could be an IP address, a user-agent,
>> or a cookie for example. Many people like the cookie because you already
>> need to force one for the persistence, so if you can force one, you can
>> force a second one. When this rule is matched, then haproxy will send
>> your request to the server associated with the persistence cookie,
>> whatever its state, and will not redispatch the request in case of
>> failure. This statement was created exactly for the need you describe
>> here.
>>
>> So let's consider the following setup :
>>
>>     listen pub
>>        bind :80
>>        cookie SRV
>>        server srv1 1.1.1.1:80 cookie s1
>>        server srv2 1.1.1.2:80 cookie s2
>>        acl its_me hdr_sub(cookie) TEST=true
>>        force-persist if its_me
>>
>> Then you configure your browser to send two cookies :
>>
>>  SRV=srv1
>>  TEST=true
>>
>> and you send any request you want there. You'll always be sent
>> to server1.
>>
>> Cheers,
>> Willy
>>
>>
>
>
>
> --
> Guillaume Bourque, B.Sc.,
> consultant, infrastructures technologiques libres
> 514 576-7638,  http://ca.linkedin.com/in/GuillaumeBourque/fr
>
>
Received on 2011/05/29 17:34

This archive was generated by hypermail 2.2.0 : 2011/05/29 17:45 CEST