【问题标题】:How to block access to sub-domain by IP address如何通过IP地址阻止对子域的访问
【发布时间】:2016-05-17 16:40:30
【问题描述】:

我正在使用 Azure Web 应用程序,需要阻止对我的上线前环境的访问。

我已尝试使用此处提出的建议,但似乎不起作用:https://learnwithshahriar.wordpress.com/2015/08/06/azure-website-101-restrict-access-on-your-staging-site/

我的例子:

<rewrite>
  <rules>
    <rule name="Block unauthorized IP to dev site" stopProcessing="true">
      <match url=".*" />
      <conditions>
        <add input="{HTTP_HOST}" pattern="^dev-slot.example.com" />
        <add input="{REMOTE_ADDR}" pattern="111.222.333.444" negate="true"/>
      </conditions>
      <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Site is not accessible" />
    </rule>
  </rules>
</rewrite>

它基本上什么都不做,我尝试了各种小改动都没有效果。

【问题讨论】:

    标签: azure iis url-rewriting web-config azure-web-app-service


    【解决方案1】:

    Matt,您是否只想在 web.config 中阻止 IP 地址?我在 Azure Web App 中测试了以下内容,并且能够阻止访问。希望这会有所帮助。

    <configuration>
       <system.webServer>
          <security>
            <ipSecurity allowUnlisted="true">    
               <clear/> <!-- removes all upstream restrictions -->
               <add ipAddress="83.116.19.53"/>   <!-- block one IP  -->                
               <add ipAddress="83.116.119.0" subnetMask="255.255.255.0"/>   <!--block network 83.116.119.0 to 83.116.119.255-->               
            </ipSecurity>
          </security>
          <modules runAllManagedModulesForAllRequests="true"/>
       </system.webServer>
    </configuration>
    

    参考网站:https://www.stokia.com/support/misc/web-config-ip-address-restriction.aspx

    【讨论】:

    • 仅适用于某些域。我们在 Azure 中使用交换功能。这意味着当您从暂存环境切换到 prod 时,配置会随之而来。因此,我们必须进行某种配置操作,这意味着将脚本带入我们的部署工具中,大惊小怪。希望我可以指定我的开发域并限制对这些域的访问。
    • 我遇到了和你一样的问题。似乎您必须愿意手动更改服务器才能完成工作。我们使用的自动化过程会自动启动服务器并进行所有交换。我们已经为我们的非生产环境完成了代码端 IP 白名单。当您准备好进行生产部署到生产 Web 应用程序时,启动非产品 Web 应用程序并在那里进行开发可能是另一种选择。不确定这有多大帮助,但据我所知,您正在寻找的选项非常有限。
    猜你喜欢
    • 1970-01-01
    • 2020-03-06
    • 2014-12-16
    • 1970-01-01
    • 2019-03-17
    • 1970-01-01
    • 2015-11-12
    • 2011-03-16
    • 2010-12-05
    相关资源
    最近更新 更多