Nginx to iis forwarding Error 400 Nginx to iis forwarding Error 400 nginx nginx

Nginx to iis forwarding Error 400


Had the same issue. It was caused by the fact that the server DNS name was resolving to an IPv4 address only, when "localhost" had both IPv4 and IPv6.

When NGINX tried to resolve an upstream "http://localhost" it was getting "::1" and switching to IPv6 - but HTTP.SYS (IIS network layer for the sake of discussion) later got an IPv4 address for the name specified in a "Host:" header.

This situation is not properly handled, despite the fact that the symbolic name, "localhost", IPv4 address and "::1" IPv6 one actually belong to the same machine.

Workaround - remove proxy_set_header Host $host; directive or use numeric upstream address in proxy_pass URI.