How to Limit Connections per IP using mod_limitipconn on cPanel

Problems one of our clients had on their cPanel servers was that some people were using download managers to download files from the server, so hundreds and sometimes thousands of connections were being ESTABLISHED to Apache which would trigger an alert on our IDS systems that a pontental ddos attack was occuring and at the same time the clients Apache was become non responsive.
so here is what we did to limit connections per IP in a cPanel hosting server :
there is an Apache module named mod_limitipconn which will take care of it for us.
first download the latest version of mod_limitipconn from this site : dominia.org
decompress and install it.
at current time the latest version is 0.24.

1
2
3
4
wget http://dominia.org/djao/limit/mod_limitipconn-0.24.tar.bz2
tar jxvf mod_limitipconn-0.24.tar.bz2
cd mod_limitipconn-0.24
/usr/local/apache/bin/apxs -cia mod_limitipconn.c

next step is to add the required configuration to the Apache config file , we can add this directly to the end of httpd.conf file but the problem is that if we do this , the httpd.conf will be overwritten by easyapache so we will use include files to add our config.
login into your WHM panel , and follow the following menu items :
Main >> Service Configuration >> Apache Configuration >> Include Editor
on the Post VirtualHost Include section , choose All Versions from drop down menu and add the following config into it :

1
2
3
4
5
6
<IfModule mod_limitipconn.c>
<Location />
MaxConnPerIP 10
NoIPLimit images/*
</Location>
</IfModule>

then click on update and restart Apache server.

kbadmin has written 149 articles

Loading Facebook Comments ...

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.