I'm setting up an HAProxy in front of only 2 backend servers, with a particular configuration: any request should go to server A; but, if server A returns a 5xx error code, all request should go to a backup server B. When A returns "up", all the requests should go to A.
I'm trying this configuration:
backend example_cluster
balance roundrobin
option httpclose
option forwardfor
option httpchk HEAD /ping.html HTTP/1.0\r\nHost:www.example.com
http-check disable-on-404
default-server error-limit 1 on-error mark-down
redirect scheme https if !{ ssl_fc }
server node1 1.2.3.4:80 check observe layer7
server node_back 5.6.7.8:443 backup ssl verify none
But it doesn't work for two reasons:
- All requests are routed to server node_back (B), even if node1 (A) is up.
- It seems that no httpchecks are performed against server A; or better, in syslog I don't see any error regarding the server A down.
If I remove the "option httpchk" line, and the two lines just below that; and I remove also the "observe layer7" in server A; HAProxy works by routing all requests to node A. But, obviously, when the server A returns a 500, HAProxy does not switch to B. So, I'm assuming that the problem might be in the option httpchk configuration.