I'm struggling with a scenario that I've searched and read so much but couldn't find anything to solve it.
I have 3 servers, 2 actives and one as a standby(backup). every time one of active servers go down, the standby server will be active and traffic load balance between 2 server (not just standby server).
I am able to solve this problem with two backends, BUT I need just one backend.
#### Fronend Configuration #####
frontend webserver
bind 192.168.64.100:80
default_backend appserver
#### Backend Configuration #####
backend appserver
balance roundrobin
server Node-1 192.168.64.132:80 check
server Node-2 192.168.64.133:80 check
server Node-3 192.168.64.134:80 check
I want Node-3 be the standby server. if Node-1 or Node-2 isn't accessible, Node-3 take the place
Best Answer
Take a look here: https://www.haproxy.com/blog/failover-and-worst-case-management-with-haproxy/
It looks like by default the backup servers only take effect when all of the primary servers are offline. So it seems like if Node-1 is down and Node-2 is still up, it should still be serving with only Node-2. If both Node-1 and Node-2 are offline, Node-3 would be used. It's possible your situation is occurring because some config is indicating that when 50% of servers are unavailable, the backup should be triggered (perhaps this is default?).
But if you look further at that page, you can set logic to trigger a backup group when a certain amount of servers in the primary fail. With only three servers in the set, I'm not sure how you'd properly accomplish that bilaterally but you could set if 1 of the 2 fails, trigger a backup of two which includes a primary. Honestly it make more sense to leverage all three in the primary group unless you pay a penalty for using it (e.g. hosted services).