zoukankan      html  css  js  c++  java
  • Windows Azure Web Site (14) Azure Web Site IP白名单

      《Windows Azure Platform 系列文章目录

      我们知道,在Azure Cloud Service和Virtual Machine,可以通过Endpoint ACL (Access Control List)访问控制列表。来设置IP白名单规则。

      具体请参考:Windows Azure Virtual Network (10) 使用Azure Access Control List(ACL)设置客户端访问权限

      在默认情况下,Azure Web Site是没有IP白名单的。也就是说,所有Internet上的用户,都可以访问Azure上的服务。

      那这样会产生一个问题,假设我要在Azure Web Site上实现IP白名单,应该如何实现呢?在这章笔者简单介绍一下。

      我们可以通过Web.config文件,来定义system.webServer节点,设置哪些IP可以访问Azure Web Site。

      1.设置IP白名单

      IP白名单的规则是这样设置的

      (1)默认禁止所有的访问

      (2)增加允许访问的公网IP地址

      

      上图中,我们设置了system.webServer节点。

      在ipSecurity节点中

      -  allowUnlisted设置为true。则允许所有公网IP访问Azure Web Site服务

      -  allowUnlisted设置为false。则默认所有公网IP不允许访问Azure Web Site服务

      -  denyAction设置为NotFound,则所有被禁止访问Azure Web Site服务的公网IP,报错信息为Not Found

      

      在上图中,我们设置的规则是:

      (1)默认情况下,所有公网IP不允许访问Azure Web Site服务

      (2)增加一条IP白名单规则,允许公网IP地址为167.220.232.192的公网IP,访问Azure Web Site服务

      (3)增加一条IP白名单规则,允许公网IP地址为202.96.0.0,子网为255.255.0.0的公网IP,访问Azure Web Site服务

      显示效果:

      (1)我本地计算器的公网IP地址为167.220.232.192,可以访问Azure上的服务

      

      (2)我在Azure上的一台虚拟机,公网IP是42.159.227.98。这个IP不在上面的IP白名单里,所以报错信息为我们定义的Not Found。如下图:

      

      

      2.设置IP黑名单

      IP黑名单的规则是这样设置的

      (1)默认允许所有的访问

      (2)增加禁止访问的公网IP地址

      system.webServer节点设置,如下图所示:

      

      -  allowUnlisted设置为true。则允许所有公网IP访问Azure Web Site服务

      -  增加一条IP黑名单规则,禁止公网IP地址为167.220.232.192的公网IP,访问Azure Web Site服务

      

      

      显示效果:

      (1)我本地计算器的公网IP地址为167.220.232.192,禁止访问Azure上的服务

      

      

      (2)我在Azure上的一台虚拟机,公网IP是42.159.227.98。这个IP不在上面的IP黑名单里,所以显示正常:

      

      

      参考资料:

      https://azure.microsoft.com/en-us/blog/ip-and-domain-restrictions-for-windows-azure-web-sites/

      https://msdn.microsoft.com/en-us/library/ms691353(v=vs.90).aspx

      

      

  • 相关阅读:
    JavaScript
    LeetCode(17)Letter Combinations of a Phone Number
    LeetCode(96)Unique Binary Search Trees
    LeetCode(16)3Sum Closest
    Python更换pip源,更换conda源
    LeetCode(15)3Sum
    LeetCode(94)Binary Tree Inorder Traversal
    LeetCode(14)Longest Common Prefix
    LeetCode(29)Divide Two Integers
    LeetCode(12)Integer to Roman
  • 原文地址:https://www.cnblogs.com/threestone/p/5151733.html
Copyright © 2011-2022 走看看