首页 文章

IIS URL重写ARR问题

提问于
浏览
0

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

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

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

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>

1 回答

  • 0

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

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

    这对我有用,解决了我的重定向问题 .

相关问题