设置Azure WebSite黑白名单

Azure WebSite服务默认是不提供黑白名单,也就是说任何Internet用户都可以访问Azure WebSite,那么我们如何来给我们的网站设置黑白名单?

这里有一种方式,可以通过配置网站的配置文件(Web.config)来设置访问的黑白名单。

1、通过VS新建一个ASP.Net MVC项目

上图我已经打开网站的配置文件(Web.config)

2、给Azure WebSite网站设置白名单

首先百度查看本机的公网IP地址

通过Web.config文件中system.webServer节点下来设置访问网站的白名单,将本地公网IP加入白名单。

  <system.webServer>
    <!--设置白名单-->
    <security>
      <ipSecurity allowUnlisted="false" denyAction="NotFound">
        <add allowed="true" ipAddress="101.231.141.202"/>
      </ipSecurity>
    </security>
  </system.webServer>

 编译之后,部署到Azure WebSite中,本机访问

使用一台公网IP为139.219.198.246的机器访问

 

3、给Azure WebSite网站设置黑名单

上面我们已经查过本机公网IP为:101.231.141.202

 通过Web.config文件中system.webServer节点下来设置访问网站的黑名单,将本地公网IP加入黑名单。

  <system.webServer>
    <!--设置黑名单-->
    <security>
      <ipSecurity allowUnlisted="true" denyAction="Forbidden">
        <add allowed="false" ipAddress="101.231.141.202"/>
      </ipSecurity>
    </security>
  </system.webServer>

编译之后,部署到Azure WebSite中,本机访问

 

 使用一台公网IP为139.219.198.246的机器访问

 

posted @ 2017-02-13 14:56  公羊天纵  阅读(949)  评论(0编辑  收藏  举报