简体   繁体   English

IIS 反向代理干扰重定向位置标头

[英]IIS reverse proxy interfering with redirect location header

I have the following rewrite rule on an ASP.Net site to get IIS to act as a reverse proxy:我在 ASP.Net 站点上有以下重写规则,以使 IIS 充当反向代理:

<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.所以基本上,在domain.com/u/* domain.com/d/*domain.com/c/*路径上的任何东西都会被转发到本地服务器。 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 .我让本地服务器返回一个301 Permanent Redirect并将Location标头设置为子域,例如: 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.问题是 IIS 正在重写Location标头以使其看起来像domain.com/somePath ,它正在完全删除子域。 I confirmed that its an IIS issue by accessing the site at domain.com:12949 and it redirects properly to the subdomain.我通过访问domain.com:12949的站点确认这是一个 IIS 问题,并且它正确重定向到子域。 How can I stop IIS from re-writing the Location header from the local server?如何阻止 IIS 从本地服务器重写Location标头?

Url rewrite can rewrite headers in responses, but should not do this by default. Url rewrite 可以重写响应中的标头,但默认情况下不应这样做。 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 .在 IIS 管理器中,选择当前服务器(而不是网站),打开Application Request Routing ,在右侧列中将有一个选项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: https://docs.microsoft.com/en-gb/archive/blogs/chiranth/application-request-routing-part-2reverse-proxy-and-troubleshooting-arr-urlrewrite-issues在此 URL 上有一些 ARR 模块窗口的屏幕截图供参考: https : //docs.microsoft.com/en-gb/archive/blogs/chiranth/application-request-routing-part-2reverse-proxy-and-troubleshooting -arr-urlrewrite-issues 在此处输入图片说明 在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 IIS 7反向代理背后的Websocket服务器 - Websocket Server Behind IIS 7 Reverse Proxy Kestrel + IIS反向代理请求未被触发 - Kestrel + IIS Reverse Proxy RequestAborted Not Triggered IIS 反向代理背后的 WebApp 在通过 OIDC 对外部 IdentityServer 进行身份验证时设置了错误的 signin_oidc redirect_uri - WebApp behind IIS reverse proxy sets wrong signin_oidc redirect_uri while authenticating against external IdentityServer via OIDC 使用反向代理使用SSL(https)配置IIS托管的WCF服务 - Using reverse proxy to configure IIS hosted WCF services with SSL(https) MVC IgnoreRoute /?_ escaped_fragment_ =继续使用IIS ARR进行反向代理 - MVC IgnoreRoute /?_escaped_fragment_= to continue Reverse Proxy with IIS ARR 在同一台服务器上具有Windows身份验证的IIS反向代理获得访问被拒绝 - IIS reverse proxy with windows authentication on same server getting access denied IIS7 URL重写为WCF请求返回404(反向代理) - IIS7 URL Rewrite returns 404 for WCF requests (reverse proxy) 如何在本地 IIS 中设置反向代理 - How do I setup reverse proxy in local IIS 从httpwebresponse位置标头重定向到URL - Redirect to an URL from httpwebresponse Location header WCF 使用反向代理 - WCF using Reverse proxy
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM