[Nagiosplug-devel] [ nagiosplug-Bugs-2638765 ] check_http has wrong HTTP version when using "Host:"

SourceForge.net noreply at sourceforge.net
Tue Mar 17 09:04:38 CET 2009


Bugs item #2638765, was opened at 2009-02-25 17:24
Message generated for change (Comment added) made by dermoth
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=397597&aid=2638765&group_id=29880

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: General plugin execution
Group: v1.4.14
>Status: Closed
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: Thiago Figueiro (thiagocsf)
Assigned to: Thomas Guyot-Sionnest (dermoth)
Summary: check_http has wrong HTTP version when using "Host:"

Initial Comment:
The "Host" header does not exist in HTTP 1.0, but in HTTP 1.1 (see RFC for HTTP 1.0 http://www.faqs.org/rfcs/rfc2616.html and HTTP 1.1 http://www.faqs.org/rfcs/rfc1945.html)

The 1.4.13 (latest release) version of check_http issues requests like:

GET /myurl HTTP/1.0
User-Agent: check_http/v2053 (nagios-plugins 1.4.13)
Connection: close
Host: mydomain.com

This will cause web servers and load balancers to ignore the "Host: mydomain.com" header because the request was specified as HTTP/1.0.

The correct request is (notice "GET" line):

GET /myurl HTTP/1.1
User-Agent: check_http/v2053 (nagios-plugins 1.4.13)
Connection: close
Host: mydomain.com

A quick-and-dirty patch to fix this issue is below.

--- plugins-orig/check_http.c   2009-02-26 09:11:55.000000000 +1100
+++ plugins/check_http.c        2009-02-26 09:07:46.000000000 +1100
@@ -783,7 +783,11 @@
   }
 #endif /* HAVE_SSL */

+  if (host_name) {
+    asprintf (&buf, "%s %s HTTP/1.1\r\n%s\r\n", http_method, server_url, user_agent);
+  } else {
   asprintf (&buf, "%s %s HTTP/1.0\r\n%s\r\n", http_method, server_url, user_agent);
+  }

   /* tell HTTP/1.1 servers not to keep the connection alive */
   asprintf (&buf, "%sConnection: close\r\n", buf);



Best regards,
Thiago.


----------------------------------------------------------------------

Comment By: Thomas Guyot-Sionnest (dermoth)
Date: 2009-03-17 04:04

Message:
This problem is now fixed in Git. Thank you for your report.

----------------------------------------------------------------------

Comment By: Thomas Guyot-Sionnest (dermoth)
Date: 2009-02-26 06:37

Message:
Thanks for your patch. This is actually something that was fixed long time
ago, but I reverted it because it was removing the :port part of the host
header. I proposed a new patch but the follow-up was never done.

There have been many changes since then so I doubt it will apply; I'll
look very soon and re-apply it.

See this thread for more details:
http://archive.netbsd.se/?ml=nagiosplug-devel&a=2008-08&m=8377448

Related commits:
31efea1b490a12a64ce0359c2d847a381d2efb7b (2050)
0378f34d85e4fa2d83bae745c44649ccfb9744bb (2030)


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=397597&aid=2638765&group_id=29880




More information about the Devel mailing list