Thursday 12 September 2013

Mod_Security



######################### APACHE START #########################


#wget "http://archive.apache.org/dist/httpd/httpd-2.2.21.tar.gz"

#tar -zxvf httpd-2.2.21.tar.gz

#cd httpd-2.2.21

#./configure  --prefix=/opt/apache1

#make

#make install

#rm -rf /softwares/httpd-2.2.21

#vi /opt/apache1/conf/httpd.conf
Listen 81
User apache
Group apache
Include conf/php.conf


#cp /etc/httpd/modules/libphp5* /opt/apache1/modules/
#cp /etc/httpd/conf.d/php.conf /opt/apache1/conf/
#/opt/apache1/bin/apachectl -k restart

######################### APACHE END #########################





######################### Mod_Security START #########################

#yum install apr-devel
#yum install pcre-devel
#yum install libxm*

Downlaod package form official download :
#wget http://www.modsecurity.org/download/modsecurity-apache_2.5.13.tar.gz
#tar zxvf modsecurity-apache_2.5.13.tar.gz
#cd modsecurity-apache_2.5.13/apache2/

#./configure --with-apr=/usr/bin/apr-1-config
OR
./configure --with-apr=/usr/bin/apr

OR
./configure --prefix=/usr/local --with-apxs=/usr/local/sbin/


# make;make install


vi /etc/httpd/conf/httpd.conf (Add one line to your configuration to load module. you may find module under /usr/local/apache2/modules/)

LoadModule security2_module modules/mod_security2.so


# service httpd restart
Thats it, now you may check the loaded module.
#httpd -M |grep security

Syntax OK

#mkdir -p /etc/modsecurity2/base_rules/
#cd /etc/modsecurity2/base_rules/

wget http://www.modsecurity.org/download/modsecurity-core-rules_2.5-1.6.1.tar.gz
#tar -zxvf modsecurity-core-rules_2.5-1.6.1.tar.gz

#vi /etc/httpd/conf/httpd.conf (Add Following in Your Apache Config File)

<IfModule mod_security2.c>
# ModSecurity2 config file.
#
Include /etc/modsecurity2/base_rules/*conf
</IfModule>

Now Your mod security is working (On Detection Mode)

Goto Browser & Access :-

http://172.16.16.247


Your can check this bye accessing error log & access log of apache.

#tail -f /var/log/httpd/error_log
#tail -f /var/log/httpd/access_log

######################### Mod_Security END #########################

No comments:

Post a Comment