URL ReWriting to a different server - rules are ignored and default website is answering requests

795 views Asked by At

I'm struggling with IIS' URL Rewrite and ARR Modules.

Basically, here's the current state of affairs:

  • I have a main webserver, awnsering all of my requests. Let's name this MAINWEBSERVER.
  • I have a secondary server with a specific application that's working as intended if you access it internally but needs to be exposed to the outside via domain to work as a webservice. Let's name this server APPSERVER.

I wish to receive my requests on MAINWEBSERVER and rewrite the URL if it matches my wildcard.

In this case, my Wildcard is https://example.com/MYAPPLICATION* .

And my desired redirect is https://APPSERVER/MYAPPLICATION/WhateverIsLeftInTheUrl .

So here's my rule sitting on my MAINWEBSERVER:

            <rewrite>
                <rules>
                    <rule name="Rewrite to Application" patternSyntax="Wildcard" stopProcessing="true">
                        <match url="https://example.com/MYAPPLICATION*" />
                        <action type="Rewrite" url="https://APPSERVER/MYAPPLICATION{R:1}" logRewrittenUrl="true" />
                    </rule>
                </rules>
            </rewrite>

NOTE: I need the URL rewritten for certificate SAN purposes (it won't validate APPSERVER/MYAPPLICATION, so I want to use a mask that is validated by my certificate, such as https://example.com/MYAPPLICATION).

The steps I took were:

  • Installing ARR (activating proxy settings);

  • Installing URL ReWrite Module;

  • Configuring wildcard rule for https://example.com/MYAPPLICATION;

  • Configuring rewrite for https://APPSERVER/MYAPPLICATION{R:1} (in case it has querystrings I wish to keep them);

  • Generated personal certificates to validate HTTPS requests between MAINWEBSERVER and APPSERVER;

Whenever I make my request the rule is ignored (despite the same URL matching the wildcard perfectly) and the default website application awnsers, considering my wildcard a querystring parameter.

I've tried this both at server level and at default website level, even with Reverse Proxy Rules. I also have experimented with Fiddler and Failed Request Tracing but to no effect. In the FRT all that is displayed is a 302 HTTP CODE and in the end a 200 Status Code when the default website loads.

Note that I believe this was working on a different server before, using this same rule although there was no default website.

0

There are 0 answers