Guy*_*Guy 15 url-rewriting iis-7.5 outbound http-headers arr
我在IIS 7.5站点上进行了URL重写设置:http://site1.com/
这充当了第二个站点的反向代理:http://site2.com/
以下是事件流:
1.浏览器在http://site1.com/somepath上执行GET
2.这会传递到site2,因为site1是URL Rewrite reverse proxy.这很好,主机设置正确,因为我已经完成了需要这个的mod.
3. site2以301状态响应,并将HTTP Location标头设置为http://site3.com/somenewpath
4. site1使用301响应浏览器,但用site1 替换 Location标头中的主机:http:// site1 .COM/somenewpath
我想在第4步中发生的是,site1 在HTTP Location标头中以http://site3.com/somenewpath响应并直接传递此数据.我觉得必须有一个出站规则可以应用来解决这个问题,但还没有弄清楚.
正如我在上面的评论中所说的,我认为反向代理的默认行为是不受影响地传递响应(假设没有设置出站重写规则).但是,我没有使用来自代理服务器后面的服务器的301响应来测试您的方案.
如果实际上需要特殊的出站规则,此代码将修改所有301响应的HTTP位置标头到http://site3.com/somepath
<outboundRules>
<!-- This rule changes the domain in the HTTP location header for redirect responses -->
<rule name="Change Location Header">
<match serverVariable="RESPONSE_LOCATION" pattern="^http://[^/]+/(.*)" />
<conditions>
<add input="{RESPONSE_STATUS}" pattern="^301" />
</conditions>
<action type="Rewrite" value="http://www.site3.com/{R:1}" />
</rule>
</outboundRules>
Run Code Online (Sandbox Code Playgroud)
此规则稍微修改了URL Rewrite Module 2.0 Configuration Reference中发布的规则
| 归档时间: |
|
| 查看次数: |
15754 次 |
| 最近记录: |