How to install Mod_security

By | March 16, 2016

Mod_security Installation

There are several ways to install mod_security. Please check out the latest documentation on their website – http://www.modsecurity.org
Download http://www.modsecurity.org/download/mod_security-1.7.4.tar.gz

# tar xvzf mod_security-1.7.4.tar.gz
# cd mod_security-1.7.4/apache2
# /usr/sbin/apxs -cia mod_security.c

At the end of the compile:
“[activating module `security’ in /etc/httpd/conf/httpd.conf]”


Mod_Dosevasive Installation

What is mod_dosevasive?

“mod_dosevasive is an evasive maneuvers module for Apache to provide evasive action in the event of an HTTP DoS or DDoS attack or brute force attack. It is also designed to be a detection and network management tool, and can be easily configured to talk to ipchains, firewalls, routers, and etcetera. mod_dosevasive presently reports abuses via
email and syslog facilities.

Detection is performed by creating an internal dynamic hash table of IP Addresses and URIs, and denying any single IP address from any of the following:

  1. Requesting the same page more than a few times per second
  2. Making more than 50 concurrent requests on the same child per second
  3. Making any requests while temporarily blacklisted (on a blocking list)

This method has worked well in both single-server script attacks as well as distributed attacks, but just like other evasive tools, is only as useful to the point of bandwidth and processor consumption (e.g. the amount of bandwidth and processor required to receive/process/respond to invalid requests), which is why it’s a good idea to integrate this with your firewalls and routers for maximum protection.

This module instantiates for each listener individually, and therefore has a built-in cleanup mechanism and scaling capabilities. Because of this per-child design, legitimate requests are never compromised (even from proxies and NAT addresses) but only scripted attacks.
Even a user repeatedly clicking on ‘reload’ should not be affected unless they do it maliciously. mod_dosevasive is fully tweakable through the Apache configuration file, easy to incorporate into your web server, and easy to use.

Download
http://www.nuclearelephant.com/projects/dosevasive/mod_dosevasive.1.8.tar.gz


# tar xvzf mod_dosevasive.1.8.tar.gz
# cd /usr/tmp/mod_dosevasive.1.8.tar.gz

# /usr/sbin/apxs -cia mod_dosevasive20.c
# vi /etc/httpd/conf/httpd.conf

Add the following:
# Apache 2.x mod_dosevasive module from
# http://www.nuclearelephant.com/projects/dosevasive/
<IfModule mod_dosevasive20.c>
DOSHashTableSize 3097
DOSPageCount 2
DOSSiteCount 50
DOSPageInterval 1
DOSSiteInterval 1
DOSBlockingPeriod 10
</IfModule

# /etc/init.d/httpd restart

Run test.pl to test

# chmod +x test.pl
# ./test.pl

 

Leave a Reply

Your email address will not be published. Required fields are marked *