Updated: 28 September 2026 · Applies to: Ubuntu 24.04, Debian 12 and cPanel & WHM 138 (Apache 2.4)

mod_evasive is an Apache module that blocks an IP for a short time when it requests too many pages too quickly. It helps against small HTTP floods and brute-force attempts; it cannot stop large DDoS attacks, which must be filtered before they reach the server.

Ubuntu 24.04 / Debian 12

apt install libapache2-mod-evasive
mkdir -p /var/log/mod_evasive && chown www-data: /var/log/mod_evasive

Edit /etc/apache2/mods-available/evasive.conf (remove the # from the lines you use):

<IfModule mod_evasive20.c>
    DOSHashTableSize    3097
    DOSPageCount        5
    DOSPageInterval     1
    DOSSiteCount        100
    DOSSiteInterval     1
    DOSBlockingPeriod   10
    DOSLogDir           "/var/log/mod_evasive"
    DOSWhitelist        127.0.0.1
</IfModule>
  • DOSPageCount / DOSPageInterval: more than 5 requests for the same page within 1 second blocks the IP.
  • DOSSiteCount / DOSSiteInterval: more than 100 requests to the whole site within 1 second blocks the IP.
  • DOSBlockingPeriod: how many seconds a blocked IP receives 403 errors.
  • DOSWhitelist: addresses that are never blocked, such as your monitoring.

Note: Apache does not allow comments at the end of a directive line; put comments on their own line starting with #.

Enable it and reload: a2enmod evasive && systemctl reload apache2.

Test it

From another computer, send many quick requests (for example with ab -n 200 -c 20 https://example.com/). After the limit you should get 403 Forbidden for the blocking period. Test carefully: set the limits too low and real visitors (or your own monitoring) get blocked, especially behind shared IPs.

AlmaLinux / Rocky Linux 9

mod_evasive is not packaged for version 9. Use ModSecurity with the OWASP Core Rule Set (dnf install mod_security mod_security_crs), rate limiting in Nginx (limit_req), or Fail2Ban on the web server logs.

Note: On cPanel servers, do not install Apache modules by hand: mod_evasive is available in WHM › Software › EasyApache 4 as ea-apache24-mod_evasive (under Apache Modules), and ModSecurity is managed in WHM › Security Center.

Related services

KVM VPS hosting

NVMe SSD and full root access, with Free Basic Managed Support.

Unmanaged dedicated servers

full root access and free IPMI KVM, with Free Basic Managed Support.

Managed dedicated servers

our engineers look after the server for you, from $135 a month.

Was this answer helpful?

Still stuck? Open a ticket