我正在运行一个 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>
最佳答案
在 article , <dynamicIpSecurity>
只能使用denyByConcurrentRequests
和denyByRequestRate
阻止来自基于 The number of concurrent requests
的 IP 地址的请求或者
The number of requests over a period of time
.
尽管作为 article说,<dynamicIpSecurity>
可以Allow list of IP addresses that will not be blocked
。但是在web.config中无法配置,只能在IIS中进行配置。
因此,如果您仍想定义基于 IP 的安全限制列表,您可以使用 <ipSecurity>
如下所示:
<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>
关于azure - 在 IIS web.config 中使用动态 IP 安全设置时忽略某些 IP 或 IP 范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55385359/