IIS反向代理干扰重定向位置标头 [英] IIS reverse proxy interfering with redirect location header

查看:233
本文介绍了IIS反向代理干扰重定向位置标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ASP.Net站点上具有以下重写规则,以使IIS充当反向代理:

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>

因此,基本上,在domain.com/u/* domain.com/d/*domain.com/c/*路径上的所有内容都将转发到本地服务器.一切正常,通常来说,到目前为止,我没有任何问题.

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.

我正在本地服务器返回一个301 Permanent Redirect,其中Location标头设置为一个子域,例如:subdomain.domain.com/somePath.该子域指向一个完全不同的服务器.

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.

问题是IIS正在重写Location标头,使其看起来像domain.com/somePath,它完全删除了子域.我通过访问domain.com:12949站点确认了它的IIS问题,并将其正确重定向到了子域.如何阻止IIS从本地服务器重写Location标头?

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?

推荐答案

URL重写可以重写响应中的标头,但默认情况下不应这样做.由于未在网站的重写规则中配置此功能,因此很可能在服务器级别启用了应用程序请求路由"模块.

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.

在IIS管理器中,选择当前服务器(而不是网站),打开Application Request Routing,在右列上将有一个选项Server Proxy Settings.在此处,您会看到响应标头中的反向重写主机".选项.如果已选中,请取消选中它,然后您的问题将得到解决.

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.

此URL上有一些ARR模块窗口的屏幕截图供参考:

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

这篇关于IIS反向代理干扰重定向位置标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆