One of the biggest problems for web hosting companies is attacks from random sources. DoS and DDoS are currently a major problem for both web hosting companies and the internet in general. One software that does not provide a definitive solution but can be a temporary fix against so-called “lamer” attackers is mod_qos. Remember, better protection requires more professional solutions. This software is still quite new and has a long way to go, but we found it to be effective in our tests. We will measure its performance with more detailed tests and share with you. If you want to install and try it yourself, here is a quick “howto”. Do not forget to share your test results with us. This installation was tested on a server with Centos5, WHM 11.23.2, and Apache 2.2.8.
First, we install the pcre packages that are generally not found on cPanel servers but required by this software.
yum -y install pcre pcre-develDownload the source code, extract the archive and enter the directory:
wget http://garr.dl.sourceforge.net/sourceforge/mod-qos/mod_qos-7.4-src.tar.gz
tar zxvf mod_qos-7.4-src.tar.gz
cd mod_qos-7.4/apache2/Compile the modules with apxs and add to Apache configuration:
/usr/local/apache/bin/apxs -I/usr/include/pcre/ -iac mod_qos.c
/usr/local/apache/bin/apxs -I/usr/include/pcre/ -iac mod_qos_control.cNow compile the tools used by mod_qos — qslog and qsfilter2. Qslog creates statistics by analyzing apache access_logs. Qsfilter2 is a tool that analyzes access logs and creates rules to block suspicious requests.
cd ../tools/
make
cp qslog /usr/local/bin/
cd qsfilter/
nano MakefileIn this section, we need to modify the Makefile content. The default Apache source code path is different from cPanel servers. Therefore, replace all “../../httpd” paths in the Makefile with “/home/cpeasyapache/src/httpd-2.2.8/”. This may vary depending on your installation.
make
cp qsfilter2 /usr/local/bin
cd /usr/local/apache/conf
nano qos.confThe qos.conf file we created will be the configuration file for mod_qos settings. There are many configuration options, but we will use the simplest settings. Briefly, we will accept a maximum of 10 connections from a source IP and limit the total request limit to 100 per virtual host. Remember, the configuration of each server will change depending on its hit profile.
QSC_WorkingDirectory /var/tmp/qosc
QSC_Filter2Binary /usr/local/bin/qsfilter2
QS_SrvMaxConnPerIP 10
QS_LocRequestLimitDefault 100
<Location /qos>
SetHandler qos-viewer
</Location>Save and exit, then create the folder where mod_qos temporary files will be saved:
mkdir -p /var/tmp/qosc
chown nobody:nobody /var/tmp/qoscFinally, add qos.conf to our configuration file with Include and restart the service:
nano httpd.confAdd the following line where Include directives are:
Include “/usr/local/apache/conf/qos.conf”
service httpd restartYou can access a page with information about mod_qos operation at http://your_ip_address/qos. I recommend keeping this open only in a test environment. When finished, remove the <Location /qos> directives from qos.conf.
For more detailed settings, visit http://mod-qos.sourceforge.net/
Caution! Use it on your own risk! :D
Leave a Comment
* Your comment will be published after approval.
Comments
0No comments yet. Be the first to comment!