Apache mod_evasive 白名单无法正常工作。

Apache mod_evasive whitelist is not working properlly.

我们遇到了奇怪的情况,我们在 Ubuntu 14 上配置了 mod_evasive 和 apache 2.4。我们在白名单中添加了 google bot IP(我们正在维护一长串内部和白名单中的外部 IP)。但是 google IP 仍然被 mod_evasive 阻止。

我们已经检查了 mod_evasive 功能,它工作正常(我们已经通过将 IP 添加到白名单来使用 Apache 基准测试工具进行了测试)。下面是配置,原来IP-66.249.66.5是子网66.249.64.0/19的一部分,但是我们添加了24和32子网

   <ifmodule mod_evasive20.c>
   DOSHashTableSize 3097
   DOSPageCount  8
   DOSSiteCount  50
   DOSPageInterval 1
   DOSSiteInterval  3
   DOSBlockingPeriod  600
   DOSLogDir   /var/log/mod_evasive
   DOSEmailNotify  abc@abc.com
   DOSWhitelist 66.249.66.5 66.249.0.0/16 66.249.64.0/19
   </ifmodule>

   root@ip-10:~# apachectl -M | grep -i ev
    evasive20_module (shared)

基于https://www.linode.com/docs/websites/apache-tips-and-tricks/modevasive-on-apache,您应该使用通配符而不是子网划分。例如,如下所示(这与子网划分不完全相同):

DOSWhitelist 66.249.*.*

有时您需要屏蔽 /17 或 /19,而通配符不适用于这种情况。如果 mod_evasive 真的可以处理网络子网规范,那就太好了。