Nagios check_http为HAProxy的站点提供“HTTP / 1.0 503 Service Unavailable”

我在stackoverflow上询问了这个,但是我认为它更适合这里。

无法弄清楚这一个!

操作系统:CentOS 6.6(最新)

当使用我的nagios check_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.1返回一个HTTP / 1.0。 那么是我的check_http插件导致这个或是curl

我的服务器是不是发送HOST头? 如果是这样,我该如何解决呢?

你有没有试图把URL的“-u”选项? 我也使用了IP地址和主机名。 我也有一个HAProxy,和你在开始时一样的信息。

我用了这个命令:

 ./check_http -H example.com -I 8.8.8.8 -p 80 -u http://example.com/ 

现在这是工作!

如何解决这个问题

您必须编辑/usr/local/nagios/etc/objects/commands.cfg并将https结构“-I”更改为“-H”

这将告诉它查找主机名,而不是在服务器configuration的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$ }