2016-12-01 99 views
2

我有以下後端配置HAProxy的健康檢查:HAProxy的健康檢查不工作,但捲曲返回200 OK

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」?似乎我可以連接得很好。

回答

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 
[...]