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

查看:680
本文介绍了反向代理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://上进行GET操作site1.com/somepath

2.这会传递给site2,因为site1是URL Rewrite reverse proxy。这很好,主机设置正确,因为我已经完成了需要这个的mod。

3. site2以301状态响应,并将HTTP Location标头设置为http://site3.com/somenewpath

4. site1使用301 响应浏览器,但替换主机 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位置标头中的 http://site3.com/somenewpath 响应并执行直接传递这些数据。我觉得必须有一个出站规则可以用来解决这个问题,但还没有弄明白。

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 - >机器或站点 - >应用程序请求路由缓存 - >服务器代理设置,并取消选中在响应头中反向重写主机复选框。如果您在机器级别执行此操作,它将对所有站点生效。如果您在特定网站上进行此操作,它只会对该网站生效,并且该框中的其他网站不会受到影响。

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天全站免登陆