IIS Url Rewrite ARR issue

大憨熊 提交于 2019-12-25 09:24:36

问题


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

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.

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>

My IIS config :

<?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:


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

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.



来源:https://stackoverflow.com/questions/40385575/iis-url-rewrite-arr-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!