К сожалению, данного модуля для Apache в Debian Lenny нет, поэтому опять подключаем Squeeze (кто уже перешел — тому, естественно, не нужно).
Меняем lenny на squeeze:
# sed -i «s/lenny/squeeze/» /etc/apt/sources.list
Обновляем информацию о пакетах:
# aptitude update
И устанавливаем libapache-mod-security:
# aptitude install libapache-mod-security -y
Настраиваем Mod_Security2
Открываем файл /etc/apache2/apache2.conf
# vi /etc/apache2/apache2.conf
И вставляем правила, к примеру:
# mod_security configuration directives
# …
# Turn the filtering engine On or Off
SecFilterEngine On
# Some sane defaults
#Check if URL characters where encoded
SecFilterCheckURLEncoding On
#Check UTF-8 encoding
SecFilterCheckUnicodeEncoding Off
#Allow 1 byte characters
# Accept almost all byte values
SecFilterForceByteRange 0 255# Server masking is optional
# SecServerSignature «Microsoft-IIS/0.0»
SecAuditEngine RelevantOnly
# The name of the audit log file
SecAuditLog /var/log/apache2/audit_log
# You normally won’t need debug logging
# Debug level set to a minimum
SecFilterDebugLog /var/log/apache2/modsec_debug_log
SecFilterDebugLevel 0
# Should mod_security inspect POST payloads
SecFilterScanPOST On
# By default log and deny suspicious requests
# with HTTP status 500
SecFilterDefaultAction «deny,log,status:500»
Готово. Документация и другие примеры доступны на сайте.
Возвращаем обратно lenny (кому нужно):
# sed -i «s/squeeze/lenny/» /etc/apt/sources.list
И рестартим Apache:
# invoke-rc.d apache2 restart