您的位置:首页 > 运维架构 > Apache

[转]apache的一些必要的mod安装

2008-04-10 11:55 218 查看
 
Apache 的一些必要的 mod 安装

PS:
Apache强大指出在于方便的插件和模块技术,这里安装的是部分不常用但是很不错的模块,包括:防范拒绝服务器攻击的mod_evasive,用于防注入等安全性防范的mod_security,以及对网页进行压缩的mod_deflate等等模块
 
模块:mod_evasive
作用:防止DDOS的攻击
介绍:mod_evasive模块的前身就是mod_dosevasive
下载:http://www.nuclearelephant.com/projects/mod_evasive
安装
# tar zxvf mod_evasive_1.10.1.tar.gz
# cd mod_evasive_1.10.1
# /usr/local/apache/bin/apxs -i -a -c mod_evasive20.c
打开 httpd.conf 文件
查看是否有
LoadModule evasive20_module modules/mod_evasive20.so
如没有则加上去
并在httpd.conf里加入
#################################
DOSHashTableSize 3097
DOSPageCount 2
DOSSiteCount 50
DOSPageInterval 1
DOSSiteInterval 1
DOSBlockingPeriod 10
###################################
 
 
模块:mod_security
作用:可以加强apache的安全性特别是在防sql 注入
下载:http://www.modsecurity.org/download/
安装
# tar zxvf modsecurity-apache-1.9.tar.gz
# cd modsecurity-apache-1.9/apache2/
# /apache2/bin/apxs -cia mod_security.c
打开 httpd.conf 文件
查看是否有
LoadModule security_module modules/mod_security.so
如没有则加上去
并在httpd.conf里加入
#################################
SecFilterEngine On
SecFilterCheckURLEncoding On
SecFilterDefaultAction "deny,log,status:500"
#SecFilterForceByteRange 32 126
#SecFilterScanPOST On
SecAuditLog logs/audit_log
###
SecFilter "/././"
#####
SecFilter /etc/*passwd
SecFilter /bin/*sh
#for css attack
SecFilter "<( | )*script"
SecFilter "<(.| )+>"
#for sql attack
SecFilter "delete[ ]+from"
SecFilter "insert[ ]+into"
SecFilter "select.+from"
SecFilter "union[ ]+from"
SecFilter "drop[ ]"
###############################
 
模块:mod_deflate
作用:对网页进行压缩加快网页浏览速度
下载:apache2自带
安装
# /usr/local/apache2/bin/apxs -i -a -c /root/httpd-2.0.48/modules/filters/mod_deflate.c
查看是否有
LoadModule deflate_module modules/mod_deflate.so
如没有则加上去
编辑 httpd.conf 文件加入以下内容:
######################################
DeflateFilterNote ratio
LogFormat '"%v %h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" (%{ratio}n)' deflate
 
SetOutputFilter DEFLATE
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch /bMSIE !no-gzip !gzip-only-text/html
SetEnvIfNoCase Request_URI /.(?:gif|jpe?g|png)$ no-gzip dont-vary
#Header append Vary User-Agent env=!dont-vary

#查找Customlog 注释原来的的一行,改成
CustomLog logs/deflate_log deflate
######################################
 

######################################
SetOutputFilter DEFLATE
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch /bMSIE !no-gzip !gzip-only-text/html
SetEnvIfNoCase Request_URI /.(?:gif|jpe?g|png)$ no-gzip dont-vary
#Header append Vary User-Agent env=!dont-vary

#查找Customlog 注释原来的的一行,改成
CustomLog logs/deflate_log deflate
######################################
 

######################################
 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息