URL Rewrite Throwing 404RSS

9 replies

Last post Jan 13, 2021 09:40 AM by samwu

  • URL Rewrite Throwing 404

    Jan 08, 2021 04:37 AM|vennem|LINK

    Trying to configure a URL rewrite to strip a part of the path and change the port.  Here is my config:

    my request url should be like https://app.domain.com:443/path/subpath/subpath

    my rewritten url should be https://target.newdomain.com:8088/subpath/subpath

                <rules>
                    <rule name="Rewrite" patternSyntax="ECMAScript">
                        <match url="https://app.domain.com:443/path(.*)" />
                        <action type="Rewrite" url="https://target.newdomain.com:8088{R:1}" logRewrittenUrl="true" />
                        <conditions>
                        </conditions>
                    </rule>
                </rules>

  • Re: URL Rewrite Throwing 404

    Jan 08, 2021 07:39 AM|samwu|LINK

    Hi vennem,

    vennem

    my request url should be like https://app.domain.com:443/path/subpath/subpath

    my rewritten url should be https://target.newdomain.com:8088/subpath/subpath

    You can try below rule:

    <rules>                
    <rule name="Rewrite" patternSyntax="ECMAScript"> <match url="path/(.*)" /> <action type="Rewrite" url="https://target.newdomain.com:8088/{R:1}" logRewrittenUrl="true" /> </rule> </rules>

    If you have any questions, please let me know.

    Best regards,

    Sam

    .NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
  • Re: URL Rewrite Throwing 404

    Jan 08, 2021 01:42 PM|vennem|LINK

    Hey thanks Sam.  That resulted in a 502.3 error.  

    Also, I had to remove the :443 from http host rules since that was throwing a 404 - the http_host variable seems to pull directly from http host header not from the url.  I tried putting {SERVER_PORT} in there and it gave 502.3 also.

  • Re: URL Rewrite Throwing 404

    Jan 08, 2021 05:33 PM|lextm|LINK

    Lex Li
    Affordable IIS Consulting Services at https://support.lextudio.com/services/consulting.html
    ---------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: URL Rewrite Throwing 404

    Jan 08, 2021 07:54 PM|vennem|LINK

    I already had ARR enabled.

  • Re: URL Rewrite Throwing 404

    Jan 09, 2021 02:42 AM|lextm|LINK

    vennem

    I already had ARR enabled.

    I guess you have it installed, but proxy mode is a separate setting and must be manually enabled. Please verify again.

    Besides, FRT should show you what exactly responded with 404, https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/using-failed-request-tracing-to-trace-rewrite-rules and that can tell more about what setting is missing.

    Lex Li
    Affordable IIS Consulting Services at https://support.lextudio.com/services/consulting.html
    ---------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: URL Rewrite Throwing 404

    Jan 11, 2021 07:24 AM|samwu|LINK

    Hi vennem,

    vennem

    That resulted in a 502.3 error.  

    Can you show me the detailed message of 502.3 error?  or you can refer to this link for troubleshooting: Troubleshooting 502 Errors in ARR.

    vennem

    I had to remove the :443 from http host rules since that was throwing a 404 - the http_host variable seems to pull directly from http host header not from the url.  I tried putting {SERVER_PORT} in there and it gave 502.3 also.

    I did not find the :443 in your http host rules, can you show me your test?

    Best regards,

    Sam

    .NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
  • Re: URL Rewrite Throwing 404

    Jan 12, 2021 06:23 PM|vennem|LINK

    502 - Web server received an invalid response while acting as a gateway or proxy server.

    There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server.

    I've tried different sets of rules to try to get them to work.  

            <rewrite>
                <rules>
                    <rule name="SplunkLogs" stopProcessing="true">
                        <match url="^path/(.*)" />
                        <action type="Rewrite" url="https://target.domain.local:8080/{R:1}" logRewrittenUrl="true" />
                        <conditions trackAllCaptures="true">
                            <add input="{HTTPS}" pattern="ON" />
                            <add input="{HTTP_HOST}" pattern="app.domain.com" />
                            <add input="{SERVER_PORT}" pattern="443$" />
                        </conditions>
                    </rule>
                </rules>
            </rewrite>

  • Re: URL Rewrite Throwing 404

    Jan 12, 2021 06:28 PM|vennem|LINK

    I just got it to work actually.  It was a certificate error.  The cert on the target was self-signed so once I manually trusted that cert it went thru fine.

  • Re: URL Rewrite Throwing 404

    Jan 13, 2021 09:40 AM|samwu|LINK

    Hi vennem,

    vennem

    I just got it to work actually.  It was a certificate error.  The cert on the target was self-signed so once I manually trusted that cert it went thru fine.

    Is your problem solved?

    Best regards,

    Sam

    .NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.