当反向代理 301 重定向时,URL 重写保留原始主机位置 [英] URL Rewrite keeps original host Location when reverse proxy 301 redirects

查看:46
本文介绍了当反向代理 301 重定向时,URL 重写保留原始主机位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 IIS 7.5 站点上设置了 URL 重写:http://site1.com/

I have URL Rewrite setup on an IIS 7.5 site: http://site1.com/

这充当第二个站点的反向代理:http://site2.com/

This acts as a reverse proxy to the second site: http://site2.com/

以下是事件流程:
1. 浏览器在 http://site1.com/somepath
上执行 GET2. 这会传递到 site2,因为 site1 是 URL 重写反向代理.这很好用,并且主机设置正确,因为我已经完成了需要这个的 mod.
3. site2 响应 301 状态并将 HTTP Location 标头设置为 http://site3.com/somenewpath
4. site1 以 301 响应浏览器,但将 Location 标头中的主机替换为 site1:http://site1.com/somenewpath

Here is the flow of events:
1. Browser does a GET on http://site1.com/somepath
2. This gets passed through to site2 because site1 is the URL Rewrite reverse proxy. This works well and the host is correctly set because I've done the mod that requires this.
3. site2 responds with a 301 status and sets the HTTP Location header to http://site3.com/somenewpath
4. site1 responds to the browser with a 301 but replaces the host in the Location header with site1: http://site1.com/somenewpath

我希望在第 4 步中发生的是 site1 在 HTTP Location 标头中以 http://site3.com/somenewpath 响应并直接通过这些数据.我觉得肯定有一个Outbound规则可以用来解决这个问题,但还没有弄清楚.

What I want to happen in step 4 is that site1 responds with http://site3.com/somenewpath in the HTTP Location header and does a straight pass through of this data. I feel that there must be an Outbound rule that can be applied to solve this but haven't been able to figure it out yet.

推荐答案

可以应用请求路由 参与?查看 IIS -> Machine or Site -> Application Request Routing Cache -> Server Proxy Settings 并取消选中Reverse rewrite host in response headers"复选框.如果您在机器级别执行此操作,它将对所有站点生效.如果在特定站点上进行,则只会对该站点生效,框内其他站点不受影响.

Could Application Request Routing be involved? Look at IIS -> Machine or Site -> Application Request Routing Cache -> Server Proxy Settings and uncheck the "Reverse rewrite host in response headers" checkbox. If you do this at the machine level, it'll take effect for all sites. If you do it on a particular site, it'll only take effect for that site, and other sites on the box will be unaffected.

这篇关于当反向代理 301 重定向时,URL 重写保留原始主机位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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