WebサーバーにDoS耐性を付けるApacheモジュール。
はてな の社員が開発し、はてなサーバーでも使用しているそうです。

インストールは簡単で、以下からダウンロード。
http://sourceforge.net/projects/moddosdetector/

Makefileの修正
 APXS=/usr/sbin/apxs
を自分のインストールしてる場所に修正し、
 make;make install
で完了

httpd.conf に以下を追加
LoadModule dosdetector_module modules/mod_dosdetector.so
<IfModule dosdetector_module>
DoSDetection on
DoSThreshold 5
DoSHardThreshold 10
DoSPeriod 60
DoSBanPeriod 60
DoSShmemName dosshm
DoSTableSize 100
DoSIgnoreContentType .(javascript|png|jpeg|gif|css|flash)
</IfModule>

項目 内容 備考
DoSDetection DoSDetectionを有効にする on/off
DoSThreshold 第1段階の閾値(アクセス数) 閾値を超えると環境変数「SuspectDoS」が設定される
DoSHardThreshold 第2段階の閾値(アクセス数) 閾値を超えると環境変数「SuspectHardDoS」が設定される
DoSPeriod 閾値を検出する判定時間(単位:秒)  
DoSBanPeriod ブラックリストの保持時間(単位:秒)  
DoSShmemName 共有メモリ名  
DoSTableSize 共有メモリサイズ  
DoSIgnoreContentType アクセス数の対象外とするMimeType  


以下のように、mod_rewriteと組み合わせて使用するように設計されている。

DoSThresholdで負荷がかかったときに表示するページ(ただいま混み合ってますなど)に飛ばし、
DoSHardThresholdで403を返してサイトにアクセスできなくなどさせることができる。

RewriteEngine On

RewriteCond %{ENV:SuspectHardDoS} .+
RewriteCond %{REMOTE_ADDR} !^(127\.0\.0\.1)$
RewriteCond %{REMOTE_ADDR} !^(192\.168\.[0-9]+\.[0-9]+)$
RewriteCond %{REMOTE_ADDR} !^(172\.(1[6-9]|2[0-9]|3[0-1])\.[0-9]+\.[0-9]+)$
RewriteCond %{REMOTE_ADDR} !^(10\.[0-9]+\.[0-9]\.[0-9])$
RewriteCond %{HTTP_USER_AGENT} !(google|yahoo|msn) [NC]
RewriteRule .* - [F,L]

RewriteLog logs/rewrite_log
RewriteLogLevel 0


以下の内容でログが出力されるため、どのIPアドレスからDoSアタックをかけられているのかも一目瞭然ビックリマーク
[Mon Nov 17 21:36:39 2008] [notice] dosdetector: 'xxx.xxx.xxx.xxx' is suspected as DoS attack! (counter: xx)
[Mon Nov 17 21:36:40 2008] [notice] dosdetector: 'xxx.xxx.xxx.xxx' is suspected as Hard DoS attack! (counter: xx)


SoftwareDesign(ソフトウェアデザイン)2007年09月号に著者の記事が出ています。