1

I've got a server farm set up in IIS 8.5. When I inspect the HTTP_X_FORWARDED_FOR header in my application code, it gives me the correct IP address but it contains a colon and a port number.

E.g.

HTTP_X_FORWARDED_FOR    127.0.0.1:64031

I know that HTTP_X_FORWARDED_FOR can contain a comma-separated list of IPs, but I've never heard of it containing port numbers.

I've not explicitly configured 64031 to be a port number anywhere in my setup. Also, the number seems to change randomly which leads me to believe it's some kind of internal port number selected by IIS to communicate between the web farm "front-end" proxy and the back-end physical website.

I've not seen this documented anywhere on the web. Is this standard behaviour? Is it Microsoft Magic? Is it something peculiar to my setup? What exactly is that port number all about?

1 Answer 1

4

One possibility is that IIS is implementing RFC 7239, the RFC which finally ratified/created a Forwarded HTTP header, to replace the X-Forwarded-For (and X-Forwarded-Proto, etc) functionality.

I say this because RFC 7239, Section 5.3 defines the format of the forwarded host data; that section, in turn, directs the reader to RFC 7230, Section 5.4, which defines the syntax/format for the Host header. And what's notable there is the ABNF syntax for Host:

Host = uri-host [ ":" port ] ;

Notice that optional syntax for the port number? It says that having the port number is allowed, although as you rightly point out, it's very uncommon.

So this may not exactly be "standard" behavior, but per RFCs, it's legal behavior. Maybe it's something specific to Microsoft right now? But the above RFCs are the first places I've seen mention of a format for the X-Forwarded-For header (indirectly via the format for the Forwarded header) that has the port number as well as the IP address.

Hope this helps!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .