kieranbarnes Independent PHP, WordPress & CubeCart Programmer

Installing mod_evasive on cPanel and/or Apache

Posted on January 29, 2010

This guide details how to install mod_evasive on cPanel to help protect against DDOS attacks, brute force attacks  and other irritants.

It uses an internal hash table of IPs and URLs and can temporarily block web requests to anyone requesting a large number of page views, or making many concurrent requests. Properly configured it can help evade DDOS attacks and keep your customers happy.

You can integrate it with iptables and hardware firewalls too if you like.

This guide is only cPanel specific to the point where you edit the configuration file.

Check the latest version from the mod_evasive web site. It is 1.10.1 in Jan 2010.

  1. wget http://www.zdziarski.com/projects/mod_evasive/mod_evasive_1.10.1.tar.gz
  2. tar zxvf mod_evasive_1.10.1.tar.gz
  3. cd mod_evasive

I am assuming you use apxs to load dymanic modules into apache. You really should.

  1. /usr/local/apache/bin/apxs -i -a -c mod_evasive20.c

cPanel users only, we need to distill the apxs module into Apache so it isn't lost next time you rebuild or upgrade cPanel/Apache.

  1. /usr/local/cpanel/bin/apache_conf_distiller –update

cPanel users can edit /usr/local/apache/conf/includes/post_virtualhost_2.conf or use the Apache Configuration option in WHM.

Vanilla Apache users can just stick the config in their httpd.conf.

  1. <IfModule mod_evasive20.c>
  2. DOSHashTableSize 3097
  3. DOSPageCount 2
  4. DOSSiteCount 50
  5. DOSPageInterval 1
  6. DOSSiteInterval 1
  7. DOSBlockingPeriod 3600
  8. </IfModule>

Optionally you can also add the following directives;

  1. DOSEmailNotify you@yourdomain.com
  2. DOSSystemCommand "/etc/apf/apf -d %s'"
  3. DOSLogDir "/var/lock/mod_evasive"

I use APF firewall, with the DOSSystemCommand so I can automatically dop offending IPs at the firewall rather than at Apache.

Hopefully you will never see an email from mod_evasive, but you know its there, ready and waiting.


Related posts

  1. Upgrading to MySQL 5.1 in cPanel/WHM
    Upgrading to MySQL 5.1 in cPanel is currently not the easiest thing in the world....
  2. Installing memcached on CentOS (cPanel)
    Welcome to hell. No really, compared to installing memcached on Ubuntu, CentOSs really sucks. CentOS...
  3. mod_geoip Revisted including stopping spam in phpBB 2
    I've recently moved a client's forum onto a new cPanel server, previously it was on...
  4. Installing mytop on cpanel
    MyTop is one of the best MySQL monitoring tools available, written by a MySQL guru,...
  5. Anonymous apache & PHP for cPanel
    So I've started playing with cPanel/WHM recently. I've got to say it does make my...

Posted by Kieran


Comments (3) Trackbacks (1)
  1. Thank you for this guide my friend, it helped alot, in bad times, I had DDoS going on my server, and this really helped.

  2. Hello,
    thanks for your guide, unfortunately the http://www.zdziarski.com/projects/mod_evasive/mod_evasive_1.10.1.tar.gz is not found

    where I can get the mod_evasive file?


Leave a comment

(required)