我有一个配置了以下后端的HAProxy运行状况检查:
backend php_servers
http-request set-header X-Forwarded-Port %[dst_port]
option httpchk get /health
http-check expect status 200
server php1 internal_ip:80 check
HAProxy不启用服务器,但在使用CURL时,我收到200 OK响应。
Command: curl -I internal_ip/health
Response:
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 01 Dec 2016 20:53:48 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Access-Control-Allow-Origin: api.flex-appeal.nl
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-transform
为什么HAProxy不会将服务器识别为" UP"?似乎我可以很好地连接。
答案 0 :(得分:2)
正确的HTTP动词为GET
,而不是get
:
option httpchk GET /health
您还可以检查/启用stats page:LastChk
列,您会看到原因检查失败。就我而言,我收到501 Not Implemented
回复。
我可以通过执行与HAProxy相同的请求来重现它:
$ telnet localhost 80
Trying ::1...
Connected to localhost.
Escape character is '^]'.
get /health HTTP/1.0
HTTP/1.1 501 Not Implemented
Date: Thu, 01 Dec 2016 21:53:09 GMT
Server: Apache/2.4.23 (Unix) PHP/7.0.13
[...]