如何使用Azure App Service/Web App限制IP地址

Arm*_*min 8 iis ip azure azure-web-sites

web.config中的ipSecurity部分是否适用于Azure App Services?

使用托管在Azure上的Web应用程序设置简单IP地址阻止(黑名单)的步骤是什么?

Byr*_*dif 8

App Service在Networking> Ip Restrictions下为此提供了UX

知识产权限制

从这里你可以阻止一个特定的IP地址或一系列地址:

阻止IP地址

如果您想通过web.config执行此操作,则需要使用XDT Transforms

<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <system.webServer>
    <security>
      <ipSecurity xdt:Transform="RemoveAttributes(allowUnlisted)">
        <add ipAddress="204.79.197.200" allowed="true" xdt:Transform="Insert"/>
      </ipSecurity>
    </security>
  </system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)

您可以在此处阅读有关XDT转换和应用服务的更多信息:https://github.com/projectkudu/kudu/wiki/Xdt-transform-samples

  • 如何使用Azure UI阻止特定的IP地址?输入一个似乎只限制访问该IP. (2认同)
  • @JoshNoe 可以从 Azure 门户 UI 将 IP 列入黑名单。您必须首先明确创建“全部允许”规则。有关更多详细信息,请参阅本文(页面下方的 3/4)- https://docs.microsoft.com/en-us/azure/app-service/app-service-ip-restrictions (2认同)

Tom*_*SFT 2

是的,web.config 中的 ipSecurity 部分适用于 Azure 应用服务。

使用 Azure 上托管的 Web 应用程序设置简单的 IP 地址阻止(黑名单)的步骤是什么?

 <system.webServer>
        <security>
            <ipSecurity>
                <add ipAddress="x.x.x.x" allowed="false" />
            </ipSecurity>
        </security>
    </system.webServer>
Run Code Online (Sandbox Code Playgroud)

我们还可以从 IIS 管理器连接到 WebApp,然后可以轻松配置限制 IP。更多详细信息请参阅博客

在此输入图像描述