33

We own server A, and on some occasions we rewrite requests to our partner on server B.

In some cases server B will respond with a redirect to a completely different website, which is what is expected, let's say server C. However, when that redirect form server B comes back to server A, server A interprets it as a redirect to a location on iteself (A) and not as a redirect to other website - server C.

How do I take note of the redirect to the external website and actually go there, rather than assuming that redirect is on my server (and 404ing)? We're running IIS 7 with the rewrite module.

Any help much appreciated.

Valentin Kuzub
  • 11,703
  • 7
  • 56
  • 93
IISrewriteproblems
  • 331
  • 1
  • 3
  • 4

3 Answers3

70

Go to the ARR proxy settings (they're hidden under IIS -> Application Request Routing Cache -> Server Proxy Settings) and uncheck the "Reverse rewrite host in response headers" checkbox. That should be enough.

LukasRos
  • 813
  • 6
  • 6
  • 3
    Thank you **so** much! I was searching for a solution to this all day. – Kirk Woll Jul 06 '12 at 01:18
  • 2
    Given that setting is not stored within a site's Web.config, how would I adjust it via code since in my case I'm hosted in Azure so can't deploy this setting change? – ChrisF Apr 30 '14 at 02:28
  • I cannot seem to find this anywhere in IIS Manager. Where would this setting be hiding? – Dylan Oct 08 '14 at 15:38
  • @Dylan to find in IIS: In Connections (left) window, select your server, then you should see Application Request Routing Cache under IIS in the centre window. Open that and then in right window you will see Server Proxy Settings. This is for IIS 6. – Chris Purves Sep 10 '15 at 02:27
  • The person who posted this question really should accept this as the answer. This saved me. Cheers – billy_comic Sep 13 '17 at 17:42
  • This helped so much thank you... On my local development machine this was enabled by default, however on the remote integration it wasn't. Took me hours to find this post. @IISrewriteproblems accept this as the answer – Steven Yates Apr 27 '18 at 08:31
  • THIS. Ffs. why is this the default? – Andrew Bullock Mar 19 '20 at 15:58
8

If you can't change this in the GUI, you can set the config via command line.

Something like this should work:

appcmd.exe set config -section:system.webServer/proxy /reverseRewriteHostInResponseHeaders:"False" -commit:apphost
humbleice
  • 816
  • 8
  • 15
2

The "Reverse rewrite host in response headers" checkbox was in a different place for me. I'm using Windows Server 2012 R2.

It was under Connections -> Server Farms -> -> Proxy, just below the time-out settings.

In my case, checking this resolved my issues.

Cereal
  • 3,699
  • 2
  • 23
  • 36