IIS Url Rewrite ARR issue [Answered]RSS

3 replies

Last post Dec 02, 2016 10:29 AM by TBayart

  • IIS Url Rewrite ARR issue

    Nov 25, 2016 10:55 AM|TBayart|LINK

    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>

    Best regards

    Tony

  • Re: IIS Url Rewrite ARR issue

    Nov 27, 2016 10:28 PM|milope|LINK

    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.
  • Re: IIS Url Rewrite ARR issue

    Nov 28, 2016 03:36 AM|Yuk Ding|LINK

    Hi TBayart,

    It sounds like you hyperlink has been rewritten to http://localhost/search?q=url+rewrite+iis+arr+3.

    Forward the resource from backend to the external domain sounds like you were using the ARR as forward proxy, please check the configuration in server level-> application request routing cache ->server proxy setting-> Enable proxy.

    Secondly, I think the only reason for the URL is being rewritten is the reverse proxy inbound rule or the outbound rule.

    Try to add the following condition pattern to your rule:

     <conditions logicalGrouping="MatchAny">
                            <add input="{REQUEST_URI}" pattern="search" negate="true" />
                            <add input="{HTTP_HOST}" pattern="www.google.com" negate="true" />
                        </conditions>

    Besides, you could try to set the URL which is not forwarded in server farm->routing rule ->request with the following  patterns are not forwarded.

    Hope this instruction about forward proxy could help you :

    https://www.iis.net/learn/extensions/configuring-application-request-routing-arr/creating-a-forward-proxy-using-application-request-routing

    Best Regards,

    Yuk Ding

    Yuk Ding

    MSDN Community Support
    Please remember to "Mark as Answer" the responses that resolved your issue.
  • Re: IIS Url Rewrite ARR issue

    Dec 02, 2016 10:29 AM|TBayart|LINK

    Thanks everybody for your help.

    milope solution worked fine, thank you very much.