[英]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.