Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GET request to IIS returns Microsoft-HttpApi/2.0

Tags:

iis

I've got 6 identical machines running IIS and Apache. Today one of them decided to just stop serving requests. I can access all of the webapps when I try from localhost/resource but when I try from url/resource I get a 404. I did a Get request against the machine that isn't working and I get this back:

  • Server: Microsoft-HTTPAPI/2.0
  • Connection: close

Compared to a working server:

  • Server: Microsoft-IIS/8.5
  • X-Powered-By: ASP.NET
  • Content-Type: text/html

Tried searching for this problem but came up with nothing, anyone got any idea's?

like image 373
DJT Avatar asked Feb 08 '16 19:02

DJT


1 Answers

Windows has an HTTP service that manages calls to IIS and other HTTP enabled services on a windows machine. Either you need to configure it to handle your calls, or, in the case of WAMP or similar non-IIS-web-server-on-windows scenarios you may just need to turn it off.

When you see "Microsoft-HttpApi/2.0" returning error, such as 400 "bad URL" or "bad header", etc. the problem is most likely because the HTTP.sys service is intercepting your http request and terminating it because it does not meet with the minimum validation rules that are configured.

This configuration is found in the registry at HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\HTTP\Parameters. In my case, it was choking because I had a RESTful call that had a 400 character segment in the url which was 160 characters more than the default value of 260, so I

  1. added the registry parameter UrlSegmentMaxLength with a DWORD value of 512,
  2. stopped the service using net stop http
  3. started the service using net start http

I've run into these issues before and it is easy to troubleshoot but there is very little on the web that addresses it.

Try these links

  • "the underlying problem is that the client has sent a request to IIS that breaks one or more rules that HTTP.sys is enforcing"
  • enabling logging on HTTP.sys is described here
  • a list of the HTTP.sys parameters that you can control in the registry is found here.
like image 170
neoscribe Avatar answered Sep 25 '22 14:09

neoscribe