為Windows下的Apache服務(wù)器添加防DDoS模塊 |
發(fā)布時(shí)間: 2012/7/3 17:55:49 |
為Windows下的Apache服務(wù)器添加防DDoS模塊 為了防HTTP DoS或DDos攻擊,我們可能會(huì)對(duì)服務(wù)器添加很多種防護(hù)產(chǎn)品,可能會(huì)購(gòu)買專業(yè)的DDoS硬件防火墻,當(dāng)然,目前并沒有一種很成熟的技術(shù)能完全封鎖住DDoS攻擊。但如果對(duì)于小型網(wǎng)站服務(wù)器來說,Apache的evasive模塊是比較簡(jiǎn)單的處理方法,原理也很簡(jiǎn)單,判斷一段時(shí)間內(nèi),某個(gè)IP訪問的次數(shù)是否過快,如果過快,就返回403錯(cuò)誤。 但是官方的evasive模塊發(fā)布的是源代碼和linux下的RPM壓縮包,雖然可以在windows使用源代碼編譯出這個(gè)模塊來,但是由于windows系統(tǒng)本身的原因,幾乎不會(huì)在默認(rèn)的情況下安裝C語言的編譯環(huán)境,如果需要安裝這個(gè)編譯環(huán)境要安裝非常多而繁雜的軟件,操作起來非常不便。但是在LINUX系統(tǒng)下編譯好的文件卻不能在WINDOWS下使用,這是兩個(gè)系統(tǒng)核心的區(qū)別,肯定不能使用。 我在別的網(wǎng)站找到了WINDOWS下用的編譯好的DLL文件,方便使用WINDOWS系統(tǒng),同時(shí)又是Apache 2.2服務(wù)器軟件的站長(zhǎng)們使用。 安裝方法: 1、下載附件中的壓縮包,解壓并拷貝mod_dosevasive22.dll到Apache安裝目錄下的modules目錄(當(dāng)然也可以是其他目錄,需要自己修改路徑)。 2、修改Apache的配置文件http.conf。 添加以下內(nèi)容 LoadModule dosevasive22_module modules/mod_dosevasive22.dll DOSHashTableSize 3097 DOSPageCount 3 DOSSiteCount 50 DOSPageInterval 1 DOSSiteInterval 1 DOSBlockingPeriod 10 其中DOSHashTableSize 3097 記錄黑名單的尺寸 DOSPageCount 3 每個(gè)頁面被判斷為dos攻擊的讀取次數(shù) DOSSiteCount 50 每個(gè)站點(diǎn)被判斷為dos攻擊的讀取部件(object)的個(gè)數(shù) DOSPageInterval 1 讀取頁面間隔秒 DOSSiteInterval 1 讀取站點(diǎn)間隔秒 DOSBlockingPeriod 10 被封時(shí)間間隔秒 ___________________________________________ 首先,在 httpd.conf 加入 LoadModule dosevasive22_module modules/mod_dosevasive22.dll 如果需要配置,在 httpd.conf 加入: <ifmodule dosevasive22_module> DOSHashTableSize 3097 DOSPageCount 2 DOSSiteCount 50 DOSPageInterval 1 DOSSiteInterval 1 DOSBlockingPeriod 10 </ifmodule> 各參數(shù)的配置說明如下: DOSHashTableSize ?????- The hash table size defines the number of top-level nodes for each child’s hash table. Increasing this number will provide faster performance by decreasing the number of iterations required to get to the record, but consume more memory for table space. You should increase this if you have a busy web server. The value you specify will automatically be tiered up to the next prime number in the primes list (see mod_evasive.c for a list of primes used). DOSPageCount ???? This is the threshhold for the number of requests for the same page (or URI) per page interval. Once the threshhold for that interval has been exceeded, the IP address of the client will be added to the blocking list. DOSSiteCount ???? This is the threshhold for the total number of requests for any object by the same client on the same listener per site interval. Once the threshhold for that interval has been exceeded, the IP address of the client will be added to the blocking list. DOSPageInterval ????? The interval for the page count threshhold; defaults to 1 second intervals. DOSSiteInterval ????? The interval for the site count threshhold; defaults to 1 second intervals. DOSBlockingPeriod ?????? The blocking period is the amount of time (in seconds) that a client will be blocked for if they are added to the blocking list. During this time, all subsequent requests from the client will result in a 403 (Forbidden) and the timer being reset (e.g. another 10 seconds). Since the timer is reset for every subsequent request, it is not necessary to have a long blocking period; in the event of a DoS attack, this timer will keep getting reset. WHITELISTING IP ADDRESSES IP addresses of trusted clients can be whitelisted to insure they are never denied. The purpose of whitelisting is to protect software, scripts, local searchbots, or other automated tools from being denied for requesting large amounts of data from the server. Whitelisting should *not* be used to add customer lists or anything of the sort, as this will open the server to abuse. This module is very difficult to trigger without performing some type of malicious attack, and for that reason it is more appropriate to allow the module to decide on its own whether or not an individual customer should be blocked. To whitelist an address (or range) add an entry to the Apache configuration in the following fashion: DOSWhitelist 127.0.0.1 DOSWhitelist 127.0.0.* Wildcards can be used on up to the last 3 octets if necessary. Multiple DOSWhitelist commands may be used in the configuration. 下載鏈接:下載 本文出自:億恩科技【www.allwellnessguide.com】 服務(wù)器租用/服務(wù)器托管中國(guó)五強(qiáng)!虛擬主機(jī)域名注冊(cè)頂級(jí)提供商!15年品質(zhì)保障!--億恩科技[ENKJ.COM] |