Current time: 04-23-2024, 08:11 PM Hello There, Guest! (LoginRegister)


Post Reply 
[HowTo] Mod Security on debian
Author Message
hxbro Offline
Junior Member
*

Posts: 34
Joined: Feb 2007
Reputation: 0
Post: #1
[HowTo] Mod Security on debian
How to install latest mod-security on debian lenny (probably applicable to other debian based distributions), there are .debs available but they are out of date so you need to install it manually.

In my opinion no apache server should be without mod-security, it helps filter out a lot of potential security holes in software to help protect your webserver, this has saved me a number of times when running beta/old
code like vhcs/ispcp or code like phpbb/wordpress/other popular web software.

More info on modsecurity here: http://www.modsecurity.org/

1. Install required packages:

Quote:apt-get install libxml2-dev liblua5.1-0 lua5.1 apache2-threaded-dev

2. Fetch the latest mod-security (2.5.1 at time of writing)

Quote:cd /tmp
wget http://www.modsecurity.org /download/modsecurity-apache_2.5.1.tar.gz

(remove the space after .org if cutting and pasting)

3. Extract mod-security

Quote:tar zxvf modsecurity-apache_2.5.1.tar.gz

4. Enter mod-security directory

Quote:cd modsecurity-apache_2.5.1/apache2/

5. Build mod-security

Quote:./configure && make && make install

If all is well mod-security should now be in /usr/lib/apache2/modules/ and called mod_security2.so

6. Create the mod-security load file for apache to load it

Quote:vi /etc/apache2/mods-available/mod-security2.load

and add the following lines:

Quote:LoadFile /usr/lib/libxml2.so
LoadFile /usr/lib/liblua5.1.so.0
LoadModule security2_module /usr/lib/apache2/modules/mod_security2.so

and save it (ESC :wq)

7. Enable the module to load with apache (unique_id is required for mod-security, it should come standard with apache)

Quote:a2enmod mod-security2
a2enmod unique_id

8. Tell apache where to load the mod-security config

Quote:vi /etc/apache2/conf.d/mod-security2.conf

and add the following line:

Quote:Include /etc/modsecurity2/*.conf

and save it (ESC :wq)

9. Create the mod-security directories and logs

Quote:mkdir /etc/modsecurity2
mkdir /etc/modsecurity2/logs
touch /etc/modsecurity2/logs/modsec_audit.log
touch /etc/modsecurity2/logs/modsec_debug.log

10. Copy the core rules into the mod-security dirs (more info on the core rules can be found on http://www.modsecurity.org/projects/rules/index.html)

Quote:cp /tmp/modsecurity-apache_2.5.1/rules/*.conf /etc/modsecurity2

11. Update the rules so the log locations are correct

Quote:vi /etc/modsecurity2/modsecurity_crs_10_config.conf

Find SecDebugLog logs/modsec_debug.log

Replace with SecDebugLog /etc/modsecurity2/logs/modsec_debug.log

Find SecAuditLog logs/modsec_audit.log

Replace with SecAuditLog /etc/modsecurity2/logs/modsec_audit.log

and save it (ESC :wq)

12. Check apache config is ok

Quote:apache2ctl configtest

(should return Syntax OK)

13. Restart apache

Quote:/etc/init.d/apache2 restart

14. Check mod-security2 is running

Quote:cat /var/log/apache2/error.log | grep ModSecurity

[Thu Mar 27 14:56:58 2008] [notice] ModSecurity for Apache/2.5.1 (http://www.modsecurity.org/) configured.

Done!

More info on mod-security http://www.modsecurity.org/

These instructions were taken from http://www.debianitalia.org/modules/wfse...icleid=161 and updated/fixed as needed.
(This post was last modified: 11-25-2008 03:10 AM by BeNe.)
03-28-2008 01:10 AM
Find all posts by this user Quote this message in a reply
Post Reply 


Messages In This Thread
[HowTo] Mod Security on debian - hxbro - 03-28-2008 01:10 AM
RE: Mod Security on debian - gOOvER - 03-28-2008, 01:53 AM
RE: Mod Security on debian - Viktor - 04-18-2008, 07:42 AM
RE: Mod Security on debian - prale - 04-19-2008, 08:59 AM
RE: Mod Security on debian - fulltilt - 04-19-2008, 07:51 PM
RE: Mod Security on debian - Viktor - 04-19-2008, 09:43 PM
RE: Mod Security on debian - fulltilt - 04-19-2008, 09:52 PM
RE: Mod Security on debian - Viktor - 04-19-2008, 10:23 PM
RE: Mod Security on debian - fulltilt - 04-19-2008, 10:38 PM
RE: Mod Security on debian - prale - 04-21-2008, 03:30 AM
RE: Mod Security on debian - hxbro - 04-22-2008, 01:57 AM
RE: Mod Security on debian - hYemac - 05-03-2008, 11:08 AM
RE: Mod Security on debian - hxbro - 05-03-2008, 11:02 PM
RE: Mod Security on debian - Quemeros - 05-08-2008, 10:45 AM
RE: Mod Security on debian - mafia - 05-10-2008, 04:09 AM
RE: Mod Security on debian - Zothos - 05-10-2008, 04:52 AM
RE: Mod Security on debian - mafia - 05-10-2008, 06:25 PM
RE: Mod Security on debian - greatman - 05-12-2008, 02:15 AM
RE: Mod Security on debian - fulltilt - 05-12-2008, 08:41 PM
RE: Mod Security on debian - tassoman - 06-03-2008, 05:30 AM
RE: Mod Security on debian - DaSilva - 06-15-2008, 05:01 AM
RE: Mod Security on debian - Zothos - 06-15-2008, 06:02 PM
RE: [HowTo] Mod Security on debian - r3r3 - 12-24-2008, 12:20 AM
RE: [HowTo] Mod Security on debian - Lucan - 01-07-2009, 03:36 AM
RE: [HowTo] Mod Security on debian - Lucan - 10-25-2009, 09:26 PM
RE: [HowTo] Mod Security on debian - Lucan - 10-28-2009, 03:05 AM
RE: [HowTo] Mod Security on debian - Lucan - 11-01-2009, 02:23 AM

Forum Jump:


User(s) browsing this thread: 1 Guest(s)