IIS Url重写ARR问题 [英] IIS Url Rewrite ARR issue

查看:206
本文介绍了IIS Url重写ARR问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Url Rewrite模块和ARR 3将IIS配置为反向代理。
我有一个公共域,它在localhost上重定向到我的应用程序。
当应用程序重定向到另一台主机时,它的工作正常。
ie:重定向到 https:// www .google.com / search?q = url + rewrite + iis + arr + 3
我的浏览器显示 http:// localhost / search?q = url + rewrite + iis + arr + 3
失败

I configured IIS as a reverse proxy using Url Rewrite module and ARR 3. I have a public domain which redirect to my application on localhost. It's working fine excepted when the application redirect to another host. ie: redirecting to "https://www.google.com/search?q=url+rewrite+iis+arr+3" My browser shows "http://localhost/search?q=url+rewrite+iis+arr+3" which fails

托管应用程序使用带有framework.net 4.5的Asp Net Mvc。
应用程序正在使用IIS应用程序池配置中的集成管道。

The hosted application is using Asp Net Mvc with framework.net 4.5. The application is working with integrated pipeline in IIS application pool configuration.

使用Fiddler,我可以在重定向上看到以下跟踪:

Using Fiddler, I can see the following trace on redirect :

HTTP/1.1 302 Found
Cache-Control: private
Content-Length: 350
Content-Type: text/html; charset=utf-8
Location: http://localhost/search?q=url+rewrite+iis+arr+3
Server: Microsoft-IIS/7.5
X-Powered-By: ARR/3.0
X-Powered-By: ASP.NET
Date: Wed, 02 Nov 2016 16:39:18 GMT

<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="https://www.google.com/search?q=url+rewrite+iis+arr+3">here</a>.</h2>
</body></html>

我的IIS配置:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="ReverseProxyInboundRule" stopProcessing="true">
                    <match url="(.*)" />
                    <action type="Rewrite" url="http://localhost/{R:1}" />
                </rule>
            </rules>
            <outboundRules>
                <rule name="ReverseProxyOutboundRule1" preCondition="IsRedirection" stopProcessing="true">
                    <match filterByTags="A" pattern="^http(.*)" negate="false" />
                    <action type="None" />
                </rule>
                <preConditions>
                    <preCondition name="IsRedirection">
                        <add input="{RESPONSE_STATUS}" pattern="3[0-9][0-9]" />
                    </preCondition>
                </preConditions>
            </outboundRules>
        </rewrite>
    </system.webServer>
</configuration>


推荐答案

感谢在IIS.net论坛上的milope(唐')知道我是否可以发布链接)给我以下解决方案:

Thanks to milope on IIS.net forums (don't know if I can post the link) for giving me the following solution:


在服务器级应用程序请求路由缓存功能中,有
是一个链接:服务器代理设置或类似的东西。
检查
代理设置中是否检查了响应头中的反向重写主机。如果是这样,这可能是外部链接转到localhost的原因。

In the server level Application Request Routing Cache feature, there is a link that reads: Server Proxy Settings or something like that. Check if the Reverse rewrite host in response header is checked in the Proxy Settings. If so, this may be why external link go to localhost.

这对我有用并解决了我的重定向问题。

This worked for me and solved my redirect issue.

这篇关于IIS Url重写ARR问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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