Using IIS and ARR to reverse proxy returns "The server returned an invalid or unrecognized response"

StackOverflow https://stackoverflow.com/questions/20682621

  •  19-09-2022
  •  | 
  •  

Question

I'm in the process of migrating from one site to another and, although the websites sit on the same server, they aren't in the same application pool.

As such, what I'm proposing is similar to the IIS article 'Reverse Proxy with URL Rewrite v2 and Application Request Routing'.

My setup as as follows:

  • Default Website (accepts connections on *:80 and *:443).
  • New Website (accepts connections on *:81)

I've enabled proxying in the ARR module and have one rewrite rule in 'New Website'. Currently, I only have one page in the new site (new-page), but this will increase gradually as we migrate over.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Reverse Proxy to New Website" stopProcessing="true">
          <match url="^new-page" />
          <action type="Rewrite" url="http://www.mysite.com:81/new-page" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

When I go to www.mysite.com/index.htm, I see my old homepage, which is correct.

However, if I go to www.mysite.com/new-page, I receive an error:

HTTP Error 502.3 Bad Gateway

The server returned an invalid or unrecognized response

HTTP Error 502.3 - Bad Gateway - The server returned an invalid or unrecognized response

Any help with this would be greatly appreciated.

Edit:

I have also enabled WinHttp tracing, and a log of the request today can be found here at pastebin.

I have some further information (retrieved from IIS Failed Request Logging) below.

Request Diagnostics for www.mysite.com:80/new-page

Was it helpful?

Solution

It appears that ARR has an issue with headers that have spaces in.

The new application has a single header with a space, and replacing it with a hyphen fixed the issue.

OTHER TIPS

I just ran into this. However, my problem had to do with conflicting cookies.

A good test is to use a different browser (or incognito in Chrome). If it works on the other browser, it could be the cookies. Try deleting the cookies to see if that helps. If it's something you can control, try changing the cookie name between different sites/environments you may have. If it's out of your control (you're doing a reverse proxy to some tool you've purchased, this may not be possible).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top