廣告廣告
  加入我的最愛 設為首頁 風格修改
首頁 首尾
 手機版   訂閱   地圖  簡體 
您是第 6249 個閱讀者
 
發表文章 發表投票 回覆文章
  可列印版   加為IE收藏   收藏主題   上一主題 | 下一主題   
月光 手機
個人頭像
個人文章 個人相簿 個人日記 個人地圖
社區建設獎
頭銜:看我代替月亮懲罰你!看我代替月亮懲罰你!
版主
級別: 版主 該用戶目前不上站
版區: Unix-like, 網站架設
推文 x42 鮮花 x565
分享: 轉寄此文章 Facebook Plurk Twitter 複製連結到剪貼簿 轉換為繁體 轉換為簡體 載入圖片
推文 x0
[教學] Apache 防制 DoS 攻擊的 mod_dosevasive 模組
吃燒餅沒有不掉芝麻的,而開網站的沒有不被攻擊的… 奇怪了,世界上還真多無聊人士,吃飽就想如何攻擊別人的網站,不知道是什麼心態. 一種常見的攻擊是貼廣告或是莫名其妙的留言,這些都是要廣告特定的 URL,這種攻擊在 WordPress 的網站用 Spam Karma 就可以有效對付;另有一種刻意要癱瘓網站的攻擊,常見的作法就是發動很多很多的用戶端要求,持續讓網站窮於應付,用掉資源(CPU的資源,socket的資源,頻寬的資源…),而使得網站無法服務正常的使用者,這就是所謂的 DoS — Denial of Service 攻擊,我翻譯為阻絕服務攻擊。

本格平常好好的經營,也沒作什麼壞事,但卻碰過好幾次 DoS 攻擊,IP 的來源是中國及俄羅斯 . 針對 DoS 攻擊,官方的 Apache 本身並沒有提供解決之道,現在找到的是一個 3rd party 的模組,mod_evasive,用以下原理防治: Detection is performed by creating an internal dynamic hash table of IP Addresses and URIs, and denying any single IP address from any of the following:
  • Requesting the same page more than a few times per second
  • Making more than n concurrent requests on the same child per second
  • Making any requests while temporarily blacklisted (on a blocking list)
它的 README 寫對付 DDoS — Distributed DoS 也有效,可是由這幾點看不出來如何有效。
由於的使用的是在 Vista (Win32)上的 Apache,要把上面的程式 compile 出來也是很麻煩,幸好在 這裡 有 mod_dosevasive Win32 binary for Apache 2.2,可以找到一個叫 dosevasive.zip 的檔案。
用法也蠻簡單的,先載入模組,在 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> 
在作各參數微調,請自己看看以下說明,就不逐條翻譯了。



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.



月光論壇
http://bbs.dj...com/


===================================
贊助本站 -- 刊登廣告 -- 物超所值虛擬主機租用
獻花 x0 回到頂端 [樓 主] From:臺灣中華電信HINET | Posted:2008-03-25 06:13 |
lapklaman
個人文章 個人相簿 個人日記 個人地圖
小有名氣
級別: 小有名氣 該用戶目前不上站
推文 x3 鮮花 x427
分享: 轉寄此文章 Facebook Plurk Twitter 複製連結到剪貼簿 轉換為繁體 轉換為簡體 載入圖片

謝謝大大的分享


獻花 x0 回到頂端 [1 樓] From:台灣中華電信 | Posted:2010-03-10 16:07 |

首頁  發表文章 發表投票 回覆文章
Powered by PHPWind v1.3.6
Copyright © 2003-04 PHPWind
Processed in 0.058446 second(s),query:16 Gzip disabled
本站由 瀛睿律師事務所 擔任常年法律顧問 | 免責聲明 | 本網站已依台灣網站內容分級規定處理 | 連絡我們 | 訪客留言