【问题标题】:Ignore certain IPs or IP ranges while using Dynamic IP Security setting in IIS web.config在 IIS web.config 中使用动态 IP 安全设置时忽略某些 IP 或 IP 范围
【发布时间】:2019-03-27 19:46:54
【问题描述】:

我有一个正在运行的 API 和一个用于 SSR 目的的前端节点服务器。一切都在使用应用服务的 Azure 上。

节点服务器和客户端都向 API 发出请求。

我正在尝试在我的 API 的 web.config 中应用“dynamicIpSecurity”,但不希望我的节点服务器 IP 受到该安全设置的限制,因为它是受信任的“客户端”。

目标是通过此设置限制所有其他客户端 IP,以防客户端决定在未经我许可的情况下尝试对我进行 ddos​​ 攻击或负载测试我的 API 以发现漏洞。

我目前已将动态 ip 安全设置注释掉,但这就是它们的外观。

<dynamicIpSecurity>
    <!--Restricting single IP to make maximum of 20 concurrent request at a time-->
    <denyByConcurrentRequests enabled="true" maxConcurrentRequests="20" />

    <!--Restricting single IP NOT to make more than 50 requests within 3 seconds duration-->
    <denyByRequestRate enabled="true" maxRequests="50" requestIntervalInMilliseconds="3000"/>
</dynamicIpSecurity>

【问题讨论】:

    标签: azure api iis web-config


    【解决方案1】:

    article中,&lt;dynamicIpSecurity&gt;只能使用denyByConcurrentRequestsdenyByRequestRate来阻止来自基于The number of concurrent requests的IP地址的请求或 The number of requests over a period of time.

    虽然正如article 所说,&lt;dynamicIpSecurity&gt; 可以Allow list of IP addresses that will not be blocked。但是在web.config中不能配置,只能在IIS中配置。

    因此,如果您仍想定义基于 IP 的安全限制列表,您可以使用&lt;ipSecurity&gt;,如下所示:

    <security>
       <ipSecurity allowUnlisted="true">
          <add ipAddress="192.168.100.1" />
          <add ipAddress="169.254.0.0" subnetMask="255.255.0.0" />
       </ipSecurity>
       <dynamicIpSecurity enableLoggingOnlyMode="true">
           <denyByConcurrentRequests enabled="true" maxConcurrentRequests="10" />
           <denyByRequestRate enabled="true" maxRequests="30"
               requestIntervalInMilliseconds="300" />
       </dynamicIpSecurity>
    </security>
    

    【讨论】:

    • allowUnlisted="true" 是否忽略&lt;ipSecurity&gt; 下面列出的 IP?我确实希望允许任何 IP 访问 API,只是某些 IP 从&lt;dynamicIpSecurity&gt; 限制中被忽略。我也可能只是误解了 allowUnlisted="true" 的实际作用......
    • 如果你想锁定服务器,阻止访问所有 IP 地址,除非它们被列出,你可以使用allowUnlisted="false"。更多详情可以参考这个article
    • 如果对您有帮助,请将其标记为关闭问题的答案:)
    • 不幸的是,这没有帮助。我不想锁定服务器。我希望所有 IP 都可以访问 API。我只希望 &lt;dynamicIpSecurity&gt; 规则不用于某些 IP(我的节点服务器)。
    • 答案几乎是对的,需要加上allowed="true",即
    猜你喜欢
    • 1970-01-01
    • 2017-03-07
    • 2016-02-24
    • 2015-08-29
    • 2011-03-10
    • 2019-04-18
    • 2017-10-20
    • 2018-01-04
    • 2015-01-01
    相关资源
    最近更新 更多