次の方法で共有


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

Overview

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.

Solution

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:

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

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.

Conclusion

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