The port is ignored when sent as part of the host header field and a redirect happens (IIS 5.0, 5.1)(Kristofer Gafvert, June 24, 2005)
When the port is sent as part of the host header field, and IIS replies with a redirect, the port in the host header field is ignored and instead the port the client actually connected to is used. This happens for both IIS 5.0 (Windows 2000) and IIS 5.1 (Windows XP). IIS 6.0 (Windows Server 2003) however, correctly uses the port specified in the host header.
A situation when this behavior will become a problem is if a NAT device (or similar) forwards the request from the outside, to another port on IIS. For example, a user connects to the NAT device on port 80, but the NAT device is sending the request on port 8080 to the webserver.
In this situation (and a redirect is happening), IIS will respond with this:
HTTP/1.1 302 Object Moved\r\n
<head><title>Document Moved</title></head>\n<body><h1>Object Moved</h1>This document may be found <a HREF="http://www.gafvert.info:8080/Test/">here</a></body>
This means that when the user's client get this back from the webserver, the user's client will try to connect on port 8080, which will fail, because the NAT device in between the client and the webserver is expecting HTTP requests on port 80.
The same request when sent to a server running IIS 6.0 will give back this response:
HTTP/1.1 301 Moved Permanently\r\n
Date: Fri, 24 Jun 2005 17:17:29 GMT\r\n
<head><title>Document Moved</title></head>\n<body><h1>Object Moved</h1>This document may be found <a HREF="http://www.gafvert.info/Test/">here</a></body>
There is currently no fix for IIS 5.X. A workaround is to run IIS and whatever device forwarding the request on the same port. Another solution is to upgrade to IIS 6.0.
Applies to [?]
RFC 2616 Hypertext Transfer Protocol -- HTTP/1.1 (section 14.23 - Host Header Field)