mod_evasive and mod_security modules are used to secure Apache Web Server from DDoS and brute force attacks by implementing web application firewall.
Download the source
wget http://www.zdziarski.com/projects/mod_evasive/mod_evasive_1.10.1.tar.gz
tar -xzvf mod_evasive_1.10.1.tar.gz
cd mod_evasive
Compile in the mod_evasive apache module using apxs
For Apache 2
/usr/local/apache/bin/apxs -i -a -c mod_evasive20.c
For Apache 1.3
/usr/local/apache/bin/apxs -i -a -c mod_evasive.c
If the apxs path is not /usr/local/apache/bin/apxs replace it with the appropriate path
Edit your httpd.conf /usr/local/apache/conf/httpd.conf
Add the below lines:
======================
DOSHashTableSize 3097
DOSPageCount 2
DOSSiteCount 50
DOSPageInterval 1
DOSSiteInterval 1
DOSBlockingPeriod 10
DOSEmailNotify user@yourdomain.com
======================
Restart apcahe:
/etc/init.d/httpd restart