I am trying to create IIS Server Farm, and having issues with the URL Rewrite to work correctly.
Windows 10 Enterprise IIS 10
Below is the relevant configurations.
<applicationPools>
<add name="always-blue" autoStart="true">
<processModel pingingEnabled="true" pingResponseTime="00:01:30" />
</add>
<add name="always-green" autoStart="true">
<processModel pingingEnabled="true" pingResponseTime="00:01:30" />
</add>
</applicationPools>
<sites>
<site name="always-blue" id="2" serverAutoStart="true">
<application path="/" applicationPool="always-blue">
<virtualDirectory path="/" physicalPath="C:\xxx\always-up-blue" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:alwaysup-blue" />
</bindings>
</site>
<site name="always-green" id="3" serverAutoStart="true">
<application path="/" applicationPool="always-green">
<virtualDirectory path="/" physicalPath="C:\xxx\always-up-green" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:alwaysup-green" />
</bindings>
</site>
</sites>
<rewrite>
<globalRules>
<rule name="alwaysup rewrite" stopProcessing="false">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^alwaysup$" />
<add input="{SERVER_PORT}" pattern="^80$" />
</conditions>
<action type="Rewrite" url="http://alwaysup/{R:0}" />
</rule>
</globalRules>
</rewrite>
Both http://alwaysup-blue and http://always-green websites are up and work normal. However the server farm doesn't work. http://alwaysup -> Returns 502. I checked the logs with FailTracedURLs, but couldn't make much sense of that. Here are the logs ..
<webFarms>
<webFarm name="alwaysup" enabled="true">
<server address="alwaysup-blue" enabled="true">
<applicationRequestRouting hostName="alwaysup-blue" httpPort="8081" />
</server>
<server address="alwaysup-green" enabled="true">
<applicationRequestRouting hostName="alwaysup-green" httpPort="8082" />
</server>
<applicationRequestRouting>
<healthCheck url="http://alwaysup/up.html" responseMatch="up" />
<loadBalancing />
<protocol preserveHostHeader="false">
<cache enabled="true" validationInterval="00:01:00" />
</protocol>
</applicationRequestRouting>
</webFarm>
Had to add the preserveHostHeader to webfarm section of configuration.