Haproxy sticky sessions
11,359
change backend configuration :
backend backend_http
option prefer-last-server
cookie mycookies insert indirect nocache
server server1 196.168.0.125:80 check cookie server1
server server2 196.168.0.126:80 check cookie server2
or
backend backend_http
option prefer-last-server
cookie mycookies insert indirect nocache
server s1 196.168.0.125:80 check cookie s1
server s2 196.168.0.126:80 check cookie s2
Author by
Mike Thorlake
Updated on June 04, 2022Comments
-
Mike Thorlake almost 2 years
I'm trying to use
Haproxy 1.6.3 2015/12/25
and sticky sessions. I did everything according to haproxy manual, but, unfortunately, checking client browser I see that cookies aren't being added (the balancer has to return me cookies in the response after the first request but it returns me nothing and works as nothing happened (without cookies)). Everything else perfectly works, but cookies don't. I've attached my haproxy.cfg:global log /dev/haproxy/log local0 log /dev/haproxy/log local1 notice chroot /var/lib/haproxy stats socket /run/haproxy/admin.sock mode 660 level admin stats timeout 30s user haproxy group haproxy daemon defaults log global mode http option httplog option dontlognull timeout connect 5000ms timeout client 50000ms timeout server 50000ms stats enable stats auth user:pass stats uri /haproxy_stats option httpchk HEAD / HTTP/1.0 option redispatch balance roundrobin frontend frontend_http bind *:80 option forwardfor default_backend backend_http backend backend_http option prefer-last-server cookie mycookies insert indirect nocache server server1 196.168.0.125:80 check cookie s1 server server2 196.168.0.126:80 check cookie s2
Also my servers (server1, server2) are deployed on
IIS
and balancer is deployed onUbuntu 16.04 LTS