apache的一些必要的mod安裝

來源:互聯網
上載者:User

 

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
######################################

 

######################################
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.