mod_evasive is the Apache module that drops requests when a single IP or vhost exceeds a configurable rate. It’s not a WAF and not a firewall — it’s a back-pressure mechanism for the “one scraper is taking your site down” problem. On cPanel it’s available through EasyApache 4. The trick is configuring thresholds that catch abuse but not your own users.
What’s happening
mod_evasive watches a hash table of (source IP, URI) tuples in-memory. When the same IP requests the same URI more than DOSPageCount times in DOSPageInterval seconds, or the same IP makes more than DOSSiteCount total requests in DOSSiteInterval seconds, the IP is blocked at the Apache level for DOSBlockingPeriod seconds. mod_evasive does not write iptables — it just returns 403. The blocks evaporate when Apache restarts.
How to verify
httpd -M | grep evasive
grep -E "DOS|mod_evasive" /etc/apache2/conf.d/*.conf
ls -la /tmp/mod_evasive/ 2>/dev/null
grep "403" /etc/apache2/logs/access_log | awk '{print $1}' | sort | uniq -c | sort -rn | head
ab -n 200 -c 50 http://example.com/ 2>&1 | tail
The last command is a 200-request burst from your IP — if mod_evasive is active and thresholds are reasonable, the latter half should return 403.
The fix
- Install via EasyApache 4: WHM > EasyApache 4 > Customize > Apache Modules > mod_evasive. Provision.
- Baseline config in
/etc/apache2/conf.d/mod_evasive.conf:<IfModule mod_evasive24.c> DOSHashTableSize 3097 DOSPageCount 20 DOSPageInterval 1 DOSSiteCount 100 DOSSiteInterval 1 DOSBlockingPeriod 30 DOSEmailNotify ops@yourdomain.com DOSLogDir /var/log/mod_evasive </IfModule> - DOSPageCount 20 in 1 second catches scrapers without blocking legitimate AJAX-heavy pages.
- DOSWhitelist for monitoring IPs, CDN ranges (Cloudflare publishes its IP list), and management subnets. mod_evasive cannot tell the difference between abuse and uptime monitoring without help.
- Restart Apache and watch
/var/log/mod_evasive/. Tune upDOSPageCountif you see legitimate users hitting blocks; tune down if abuse still slips through. - Coexistence with CSF: mod_evasive is in-memory and fast; CSF/LFD is log-driven and slower but persistent. They complement each other. Do not use mod_evasive’s
DOSSystemCommandto add to CSF — the volume of short-lived blocks is too high. - Cloudflare in front: if Cloudflare is the front edge, configure their rate-limiting rules first; mod_evasive only sees traffic that bypasses Cloudflare (CF origin pull).
Stack Harbor configures Apache-level rate limiting where it earns its place under cPanel server administration.