How to use Application Request Routing to route to dedicated Admin web server, while retaining original request Domain

94 Views Asked by At

I am using ARR in IIS 10. I have an ARR server that receives a request for "Http://wwww.PUBLICDOMAIN/Admin" but I want the request to not route to web farm. Rather I want it to go to the dedicated "Admin" host "Http://ADMINHOST/Admin", but to show as "Http://wwww.PUBLICDOMAIN/Admin" in the browser URL. Help is appreciated, thank you.

These are the rules I have set on the ARR servers applicatioHost.config. The request is handled as expected, but the URL in the browser shows "Http://ADMINHOST/Admin" instead of "Http://wwww.PUBLICDOMAIN/Admin" as desired.

<rule name="Admin Area" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
    <match url="^(admin(/.*)?)$|^(lib_npm/.+)$" />
    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
        <add input="{HTTP_HOST}" pattern="^admin\.wf\.local$" negate="true" />
    </conditions>
    <action type="Rewrite" url="http://ADMINHOST/{R:0}" />
</rule>

<rule name="ARR_PCRWeb_loadbalance" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
    <match url=".*" ignoreCase="false" />
    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
        <add input="{PATH_INFO}" pattern="^(/admin(/.*)?)$|^(/lib_npm/.+)$" negate="true" />
    </conditions>
    <action type="Rewrite" url="http://WebFarm/{R:0}" />
</rule>
1

There are 1 best solutions below

0
YurongDai On

You need to try modifying your rules as follows:

<rule name="Admin Area" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
    <match url="^(admin(/.*)?)$|^(lib_npm/.+)$" />
    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
        <add input="{HTTP_HOST}" pattern="^www\.PUBLICDOMAIN$" />
    </conditions>
    <action type="Rewrite" url="http://ADMINHOST/{R:1}" />
</rule>

The condition {HTTP_HOST} is used to check if the request comes from www.PUBLICDOMAIN.