当前位置:网站首页>Enable application request routing on azure app service

Enable application request routing on azure app service

2020-11-10 14:28:22 osc_15vyay19

Click on the top blue word to follow “ Wang yujie blog ”

Introduction

We are IIS Often used on Application Request Routing (ARR) Module acting as reverse agent .Azure App Service Also used IIS, In principle, we should also be able to do reverse generation , But it doesn't work by default , Let's see how to give App Service Enable on ARR.

experiment

I have a website https://dropdatabase.run/, Want to be in https://dropdatabase.run/996 The next generation https://996.icu. So , I have to create the following at the root of the site web.config file .

<?xml version="1.0" encoding="UTF-8"?>

<configuration>

  <system.webServer>

    <rewrite>

      <rules>

        <rule name="996" stopProcessing="false">

          <match url="996(.*)" />

          <action type="Rewrite" url="https://996.icu/{R:1}" appendQueryString="true" logRewrittenUrl="false" />

        </rule>

<rule name="996js" stopProcessing="false">

          <match url="js/(.*)" />

          <action type="Rewrite" url="https://996.icu/js/{R:1}" appendQueryString="true" logRewrittenUrl="false" />

        </rule>

      </rules>

    </rewrite>

    <httpProtocol>

     <customHeaders>

        <add name="strict-transport-security" value="max-age=15552001; includeSubDomains; preload" />

     </customHeaders>

    </httpProtocol>

  </system.webServer>

</configuration>

In this machine , Everything is working well . But deployed to Azure in the future , incredibly 404 了 :

Actually web.config The file is correct , Not working because App Service Even though it's pre installed ARR modular , But it is not enabled by default .

resolvent

This is a method not in Microsoft documentation , After all, the strange gestures of Microsoft products have to be handed down by word of mouth .

To be in App Service Enable on ARR, You need one xdt file , And upload them to site Catalog .

Open on the site administration page  Advanced Tools

Get into  Debug console, CMD or PowerShell

Get into site Catalog

Click on  + New file

Input file name  applicationHost.xdt Then click the edit icon

Copy the following , And save the file

<?xml version="1.0" encoding="UTF-8"?>

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">

  <system.webServer>

    <proxy xdt:Transform="InsertIfMissing" enabled="true" preserveHostHeader="false" reverseRewriteHostInResponseHeaders="false" />

  </system.webServer>

</configuration>

go back to Azure App Service Website management page , Restart the website

Wait a moment , Our antipodes will work !

If you don't see this article , You may need to 996 a week , Then give up. App Service Switch to VM The deployment is reverse . Ah , Rich people's cloud , It's the need to pay attention to my official account. , It's comfortable to use .

Wang yujie blog

Azure | .NET |  Microsoft MVP

No advertisement , Don't sell classes , Be a pure technical official account.

Like the content of this article, please click to see

版权声明
本文为[osc_15vyay19]所创,转载请带上原文链接,感谢