0

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 ..

FailedReqLogFiles

Amit Shah
  • 107
  • 6
  • Please enable detailed errors in IIS and provide a detailed description of the 502 error along with the sub-status code. https://learn.microsoft.com/en-us/troubleshoot/developer/webapps/iis/application-request-routing/troubleshooting-502-errors-in-arr – YurongDai Aug 01 '23 at 06:00
  • It is enabled as far as I can understand. Error is 502 and substatus is 4. 502.4 which says appropriate server could not be found to handle the request. The appropriate server in this case being the server-farm .. – Amit Shah Aug 01 '23 at 13:44
  • Have you checked your deployment process by this tutorial? [How to use Blue-Green Deployment in IIS](https://dev.to/mark0960/deploy-web-app-to-iis-with-zero-downtime-in-visual-studio-3f5k). I followed this tutorial and no error. – YurongDai Aug 02 '23 at 09:16
  • Yes, that is the exact tutorial that I have followed ! And the server-farm url is the one that doesn't work for me. – Amit Shah Aug 08 '23 at 16:20

2 Answers2

0

trace warning: REWRITE_DISABLED_KERNEL_CACHE

This warning indicates: if a rewrite rule set uses any server variable not mentioned in the list, the rule set is considered unsafe for output caching. This means that the URL Rewrite Module will disable kernel mode caching for all requests whether the request URLs were rewritten or not. Refer to: Interaction with IIS Output Caching

But I don't think this warning is the root cause of 502 error, the problem should be in your deployment process. I followed the tutorial to use blue-green deployment in IIS and no error occurred. You can try redeploying by following the steps in this link: How to use Blue-Green Deployment in IIS.

YurongDai
  • 1,362
  • 1
  • 2
  • 7
0
    <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.

Amit Shah
  • 107
  • 6