IIS Azure Web App - Force HTTPS AlwaysOn ping should return 200 for FastCGI sites


PHP, Java and other FastCGI hosted environments should respond to an Always On ping to keep the child process warmed up.  Specifically in Azure App Services we send a request to the Root of the site with the header User-Agent: AlwaysOn.  If you are forcing HTTPS using a Url Rewrite rule, the Always On ping will get a redirect but will not follow that redirect and therefore the FastCGI module will not be hit and kept warm.


You can simply add a rule that will look for the ping to the root of your site and the User-Agent: AlwaysOn header and not force HTTPS.  The easiest way to do this is to add this Url Rewrite rule before the Force HTTPS rule as follows:

             <rule name="No HTTPS for user agent AlwaysOn and Root of site" stopProcessing="true">
               <match url="^$"/>
                 <add input="{HTTP_USER_AGENT}" pattern="^AlwaysOn$" />
               <action type="None" />

The above rule will look for a match for a request to the root and with a User-Agent header of “AlwaysOn”.  If that condition is met, no other rules are processed.


If you find this blog is useful please drop me a note!  Ref:  https://microsoftazurewebsitescheatsheet.info/  Force HTTPS