【发布时间】:2018-07-01 14:27:54
【问题描述】:
在 Azure 应用服务中,您可以通过 web.config 文件或 Azure 门户中的自定义域刀片将 HTTP 流量重定向到 HTTPS。是否可以在不进行重定向的情况下完全禁用 HTTP?
【问题讨论】:
标签: azure azure-web-app-service
在 Azure 应用服务中,您可以通过 web.config 文件或 Azure 门户中的自定义域刀片将 HTTP 流量重定向到 HTTPS。是否可以在不进行重定向的情况下完全禁用 HTTP?
【问题讨论】:
标签: azure azure-web-app-service
这是实现此目的的一种方法:
D:\home\site文件夹在该文件夹中创建一个名为 applicationhost.xdt 的文件,其内容如下(您可以从本地计算机拖放它):
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<location path="%XDT_SITENAME%" xdt:Transform="InsertIfMissing" xdt:Locator="Match(path)">
<system.webServer xdt:Transform="InsertIfMissing">
<rewrite xdt:Transform="InsertIfMissing">
<rules xdt:Transform="InsertIfMissing">
<rule name="Disable HTTP" enabled="true" stopProcessing="true">
<match url="(.*)" ignoreCase="false" />
<conditions>
<add input="{HTTPS}" pattern="off" />
<add input="{WARMUP_REQUEST}" pattern="1" negate="true" />
</conditions>
<action type="CustomResponse" statusCode="401" />
</rule>
</rules>
</rewrite>
</system.webServer>
</location>
</configuration>
这将使http请求失败并返回401(您可以在<action>标签中自定义响应)。
【讨论】: