a reverse proxy should be simple i thought but i encountered a problem. i try to accomplish the following: ive 2 webfrontends (serverA, ServerB) which hosting a webapplication contoso.local. then ive a server which is a reverse proxy on iis (with ARR & URL Rewrite)
the reverse proxy should send all incoming requests of contoso.local to serverA
if path123 is in the url it should send the request to serverB
i need to preserve the hostheader
so i configured the following on the reverse proxy:
enabled the proxy in ARR
set preservehostheader via
system.webServer/proxy"%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/proxy -preserveHostHeader:true /commit:apphost
added a new website in iss which has contoso.local as hostheader
added 2 rules with the following config described in web.config of that website contoso.local:
<rewrite> <outboundRules> <preConditions> <preCondition name="ResponseIsHtml1"> <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" /> </preCondition> </preConditions> </outboundRules> <rules> <clear /> <rule name="ReverseProxyInboundRule2" stopProcessing="true"> <match url="^path123(.*)" /> <conditions> <add input="{CACHE_URL}" pattern="^(https?)://" /> </conditions> <action type="Rewrite" url="{C:1}://serverB/{R:1}" /> </rule> <rule name="ReverseProxyInboundRule1" stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="{CACHE_URL}" pattern="^(https?)://" /> </conditions> <action type="Rewrite" url="{C:1}://serverA/{R:1}" /> </rule> </rules> </rewrite>
now if i test, ill get to serverA always. am i missing anything or is there any wrong in my logic?