I am using HAproxy to load balance between more web server. Those webservers are using PHP and sessions to keep one's session open.
Now, I think that when a user refreshes the page, it is sent to one of those servers but, if he's sent to a different server, he will of course loose his session, no?
The question is mainly: how can make it so that a client connects to the same server?
Here is my configuration for the backend.
backend social_backend
mode http
option httplog
option http-server-close
option forceclose
no option httpclose
balance roundrobin
option forwardfor
timeout queue 5000
timeout server 86400000
timeout connect 86400000
timeout check 1s
server socket1 10.10.10.1:81 weight 1 maxconn 1024 check
server socket2 10.10.10.2:81 weight 1 maxconn 1024 check
server socket3 10.10.10.3:81 weight 1 maxconn 1024 check
Best Answer
What you're looking for is "sticky sessions", and you can use
appsession
parameter in HAProxy to enable that:Refer to HAProxy documentation for more details.