Hi Runozo,
On Tue, Jan 29, 2013 at 12:30:37PM +0100, Runozo wrote:
> Greeetings and thanks for Haproxy
>
> I have the following backends configured and working with correct ACLs:
>
> backend back1
> description balanced server apps
> mode http
> cookie SRV insert nocache indirect
> balance roundrobin
> option forwardfor
> option redispatch
> option http-server-close
> option tcp-smart-connect
> option httpchk HEAD /httpcheck.asp
> server www01-sia 192.168.41.235:80 cookie 1 maxconn 200 slowstart
> 30s weight 1 check
> server www02-sia 192.168.41.236:80 cookie 2 maxconn 200 slowstart
> 30s weight 1 check
>
> backend back2
> description single server apps
> mode http
> # reqadd Cookie:\ SRV=1
> # reqidel ^Cookie:.*SRV=.*
> # cookie SRV insert nocache
> option forwardfor
> server www01-sia 192.168.41.235:80 maxconn 500 slowstart 1m check
>
> Now, i wish that when the client is on "back2", the SRV client cookie be
> always rewritten with value 1 so, when client come back to "back1" will be
> sticked to server 1
>
> Is it possible? I think yes, but cannot figure out how
Yes it's possible but that choice is strange. The easiest thing to do is
to have the same "cookie" statement in back2 as in back1 :
backend back1
description balanced server apps
mode http
cookie SRV insert nocache indirect
balance roundrobin
option forwardfor
option redispatch
option http-server-close
option tcp-smart-connect
option httpchk HEAD /httpcheck.asp
server www01-sia 192.168.41.235:80 cookie 1 maxconn 200 slowstart 30s
weight 1 check
server www02-sia 192.168.41.236:80 cookie 2 maxconn 200 slowstart 30s
weight 1 check
backend back2
description single server apps
mode http
cookie SRV insert nocache indirect
option forwardfor
server www01-sia 192.168.41.235:80 cookie 1 maxconn 500 slowstart 1m
check
This is sometimes done when applications are using different timeouts but
still want to go to the same servers. However when they do this they have
the same number of servers in both farms. Here if your clients go to back2
and then to back1, then the second server will get very little traffic.
Willy