IIS reverse proxy interfering with redirect location header

爱⌒轻易说出口 提交于 2020-01-14 04:44:22

问题


I have the following rewrite rule on an ASP.Net site to get IIS to act as a reverse proxy:

<rewrite>
    <rules>
        <rule name="AppReverseProxy" enabled="true" stopProcessing="true">
            <match url="([d|u|c]/.*)" />
            <action type="Rewrite" url="http://127.0.0.1:12949/{R:1}" />
        </rule>
    </rules>
</rewrite>

So basically, anything at a path of domain.com/u/* domain.com/d/* or domain.com/c/* will get forwarded to the local server. This works fine, and as a rule I've had no issues until now.

I'm having the local server return a 301 Permanent Redirect with a Location header set to a subdomain like: subdomain.domain.com/somePath. This subdomain points to an entirely different server.

The problem is that IIS is rewriting the Location header to look like domain.com/somePath, it's removing the subdomain completely. I confirmed that its an IIS issue by accessing the site at domain.com:12949 and it redirects properly to the subdomain. How can I stop IIS from re-writing the Location header from the local server?


回答1:


Url rewrite can rewrite headers in responses, but should not do this by default. Since this is not configured in the rewrite rule of the website, most likely the Application Request Routing module is enabled at the server level.

In IIS Manager, Select the current server (not the website), open Application Request Routing, and on the right hand column there will be an option Server Proxy Settings. There you will see "Reverse rewrite host in response headers" option. If that is checked - uncheck it and your problem should be solved.

There are some screenshots of the ARR module windows for reference at this URL: http://blogs.msdn.com/b/chiranth/archive/2014/08/03/application-request-routing-part-2-reverse-proxy-and-troubleshooting-arr-urlrewrite-issues.aspx



来源:https://stackoverflow.com/questions/32513861/iis-reverse-proxy-interfering-with-redirect-location-header

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!