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

时间:2017-08-31 21:26:49

标签: azure iis ip azure-web-sites

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

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

2 个答案:

答案 0 :(得分:7)

App Service在 Networking>下为此提供了用户体验。 Ip限制

IP Restrictions

从此处可以阻止特定IP地址或一系列地址:

Block ip addresses

如果您想通过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>

您可以在此处详细了解XDT转换和应用服务:https://github.com/projectkudu/kudu/wiki/Xdt-transform-samples

答案 1 :(得分:2)

是的,web.config中的ipSecurity部分适用于Azure App Services。

  

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

 <system.webServer>
        <security>
            <ipSecurity>
                <add ipAddress="x.x.x.x" allowed="false" />
            </ipSecurity>
        </security>
    </system.webServer>

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

enter image description here

相关问题