是否可以在各个后端服务器上执行HTTP运行状况检查,并在活动后端服务器之间进行负载平衡。 当我们在httpchk中提到主机名时,这适用于单后端服务器(选项httpchk GET / info HTTP / 1.1主机:\ abc.mysrv1.com)
但是我无法使用多个后端服务器成功配置它,因为我无法在httpchk命令上提供单独的主机名,并且在后端配置下获得http 400错误 -
backend svc.op
balance roundrobin
mode http
http-send-name-header Host
option httpchk GET /info HTTP/1.1
http-check send-state
http-request set-uri /test/abcService
server abc.mysrv1.com abc.mysrv1.com:80 check
server abc.mysrv2.com abc.mysrv2.com:80 check
[WARNING] 115/162226 (4788) : Server svc.op/abc.mysrv1.com is DOWN, reason: Layer7 wrong status, code: 400, info: "Bad Request: missing required Host header", check duration: 1ms. 1 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
[WARNING] 115/162227 (4788) : Server svc.op/abc.mysrv2.com is DOWN, reason: Layer7 wrong status, code: 400, info: "Bad Request: missing required Host header", check duration: 0ms. 0 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
[ALERT] 115/162227 (4788) : backend ' svc.op' has no server available!
$ ./haproxy -version HA-Proxy版本1.6.7 2016/07/13
更新: 我没有追求这个,但有人建议关注 -
backend h_a01
mode http
option httpchk GET /health HTTP/1.1\r\nHost:\ a01\r\n
http-check expect rstatus ^200
http-request set-uri /hello/world
http-request set-header Host a01
server a01 a01 check
backend h_a02
mode http
option httpchk GET /health HTTP/1.1\r\nHost:\ a02\r\n
http-check expect rstatus ^200
http-request set-uri /hello/world
http-request set-header Host a02
server a02 a02 check
backend a
mode http
option forwardfor
http-send-name-header Host
http-request set-uri /hello/world
server a1 a1 track h_a01/a01
server a2 a2 track h_a02/a02