在共享托管平台上禁止对 Apache 进行 DDOS 攻击的最佳方法是什么?

What is the best way to ban DDOS attacks for Apache, on a shared hosting platform?

我们有 Ubuntu 14.04 Apache 服务器,在共享托管环境中托管数千个网站,偶尔会有一个或另一个网站引起 DDOS 攻击者的注意。

问题:

检测和禁止过于活跃的 IP 地址的最佳 Apache 模块或方法是什么?

要求:

  1. 不要禁止 Googlebot 和其他合法的搜索引擎。
  2. 如果 Googlebot 正在为多个客户网站(在不同的域)编制索引,我们不想计算来自该 IP(范围)的总点击量,我们需要在每个域的基础上进行计数(当然要考虑最大总点击量)也算在内)。

Fail2ban 可以提供帮助,您需要对其进行配置以满足您的要求

Fail2ban scans log files (e.g. /var/log/apache/error_log) and bans IPs that show the malicious signs -- too many password failures, seeking for exploits, etc. Generally Fail2Ban is then used to update firewall rules to reject the IP addresses for a specified amount of time, although any arbitrary other action (e.g. sending an email) could also be configured. Out of the box Fail2Ban comes with filters for various services (apache, courier, ssh, etc).