Let's say I have 2 servers – SA and SB. Is it possible to configure HAProxy to work like this:
All connections goes to SA -> SA goes down -> HAProxy switches all connections to SB -> until SB is not down – no connections go to SA, even if it is up again -> SB down -> HAProxy switches to SA…
In brief I would like HAProxy to switch only when current server goes down. Maybe I should use sth else than HAProxy?
Best Answer
Check out this config:
All requests will hit web01 by default. web02 will not be used. If web01 stops responding, after 30s (3 checks at 10 seconds intervals) the server will be taken offline. web02 will be brought online and all requests will hit it.
If web01 recovers, it will only be brought back online once 99999999 checks at an interval of 10 seconds pass - which is effectively never.