Nagios check_http が HAProxy サイトで「HTTP/1.0 503 Service Unavailable」を返す

Nagios check_http が HAProxy サイトで「HTTP/1.0 503 Service Unavailable」を返す

私はこれをstackoverflowで質問しましたが、ここでの方が適していると思います。

これは分かりません!

OS: CentOS 6.6 (最新)

nagioscheck_httpチェック (または 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

URL に「-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パラメータを変更する必要があります。「-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$
        }

関連情報