
我在 stackoverflow 上問過這個問題,但我認為它更適合這裡。
這個想不通!
作業系統:CentOS 6.6(最新)
check_http
當使用我的 nagios檢查(或curl)查詢透過 HAProxy 1.5 提供服務的 SSL 網站時,我收到以下 503 錯誤。
[root@nagios ~]# /usr/local/nagios/libexec/check_http -v -H example.com -S1
GET / HTTP/1.1
User-Agent: check_http/v2.0 (nagios-plugins 2.0)
Connection: close
Host: example.com
https://example.com:443/ is 212 characters
STATUS: HTTP/1.0 503 Service Unavailable
**** HEADER ****
Cache-Control: no-cache
Connection: close
Content-Type: text/html
**** CONTENT ****
<html><body><h1>503 Service Unavailable</h1>
No server is available to handle this request.
</body></html>
HTTP CRITICAL: HTTP/1.0 503 Service Unavailable - 212 bytes in 1.076 second response time |time=1.075766s;;;0.000000 size=212B;;;0
[root@nagios ~]# curl -I https://example.com
HTTP/1.0 503 Service Unavailable
Cache-Control: no-cache
Connection: close
Content-Type: text/html
然而。我可以透過任何瀏覽器正常存取該網站; (200 OK),也curl -I https://example.com
來自另一台伺服器:
root@localhost:~# curl -I https://example.com
HTTP/1.1 200 OK
Date: Wed, 18 Feb 2015 14:36:51 GMT
Server: Apache/2.4.6
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Pragma: no-cache
Last-Modified: Wed, 18 Feb 2015 14:36:52 GMT
Content-Type: text/html; charset=UTF-8
Strict-Transport-Security: max-age=31536000;
HAProxy 伺服器在 pfSense 2.2 上運作。
我看到 HAProxy 從其他地方返回 nagios 的 HTTP/1.0 和 HTTP/1.1。那麼這是我的check_http
插件造成的還是它造成的呢curl
?
我的伺服器只是不發送 HOST 標頭嗎?如果是這樣,我該如何解決這個問題?
答案1
check_http 有一個名為的選項--sni
你需要使用該選項
答案2
您是否嘗試為網址新增“-u”選項?我還使用了 IP 位址和主機名稱。我也有一個 HAProxy,並且與您一開始的消息相同。
我使用了命令:
./check_http -H example.com -I 8.8.8.8 -p 80 -u http://example.com/
現在開始工作了!
答案3
這是解決這個問題的方法!
您必須編輯 /usr/local/nagios/etc/objects/commands.cfg 並更改 https arument“-I”到“-H”
這將告訴它查找主機名稱而不是伺服器配置中的 http_check 區塊中指定的 Dip 位址:/usr/local/nagios/etc/servers/yourserver.cfg
從:
# 'check_http' command definition
define command{
command_name check_http
command_line $USER1$/check_http -I $HOSTADDRESS$ $ARG1$
}
到:
# 'check_http' command definition
define command{
command_name check_http
command_line $USER1$/check_http -H $HOSTADDRESS$ $ARG1$
}