【问题标题】:Is it possible to set IP restrictions for Windows Azure Web sites?是否可以为 Windows Azure 网站设置 IP 限制?
【发布时间】:2013-09-06 09:30:10
【问题描述】:

我们使用的是 Windows Azure 网站,因此我们不创建 Web 角色。现在我们需要为网站临时设置 IP 限制,我不确定这对网站是否可行。

通常所做的是将 ipSecurity 元素添加到 web.config 中的 system.webServer 部分。但是 ipSecurity 部分默认是锁定的,所以必须先通过运行脚本命令解锁。但是 Azure 网站无法运行启动脚本,是吗?

这是否意味着对于 Azure 网站(没有 Web 角色)根本无法配置 IP 范围限制?

【问题讨论】:

    标签: asp.net security web-applications azure


    【解决方案1】:

    Nir Mashkowski 在how you can enable IP Restriction in Windows Azure Web Sites 的博客文章中解释道。

    【讨论】:

    【解决方案2】:

    AFAIK ipSecurity 在 Azure 网站上未激活。

    解决方法:您可以在 global.asax Application_BeginRequest 中编写一小段代码,然后在允许的 IP 地址列表中检查客户端 IP 地址。您可以在 Application_Start 上加载列表。

    protected void Application_BeginRequest(...)
    {
      string clientIP = request.UserHostAddress;
      if (!Check(clientIP, myOKList))
      {
        Response.Write("<html><body>You are not authorized!</body></html>");
        Response.End();
      }
    }
    

    【讨论】:

      猜你喜欢
      • 2014-09-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-17
      • 1970-01-01
      • 1970-01-01
      • 2023-03-19
      • 2011-10-30
      相关资源
      最近更新 更多