LoginSignup
8
13

More than 5 years have passed since last update.

簡単Dos攻撃対策

Last updated at Posted at 2017-07-11

前書き

今さらですが、Dos攻撃対策の1つ、mod_dosdetector について、ササっと。
設定作業をメインに記載します。
詳細は、いろいろなページがあるので、そちらでパラメータの確認を行ってください。

インストール

apxs(httpd-develに入ってます) とgcc、wget を利用するので、入ってなければ入れときましょう。

# yum install httpd-devel gcc wget
# cd /tmp
# wget http://ncu.dl.sourceforge.net/sourceforge/moddosdetector/mod_dosdetector-0.2.tar.gz
# tar zxfv mod_dosdetector-0.2.tar.gz
# cd mod_dosdetector-0.2
# make 
# make install

インストールは、これで完了です。
make やmake install したときに何かしら表示されますが、error が出なければ大丈夫!
インストールが完了すると、/etc/httpd/conf/httpd.conf がバックアップされ、
httpd.conf.bak が出来上がってます。

この1文がhttpd.confに書き込まれからですね。

LoadModule dosdetector_module /usr/lib64/httpd/modules/mod_dosdetector.so

設定しましょ。

設定

/etc/httpd/conf/httpd.conf の一番下に次の要に記載します。

RewriteEngine on
DoSDetection     on
DoSPeriod        10
DoSThreshold     100
DoSHardThreshold 100
DoSBanPeriod     3600
DoSTableSize     3000
RewriteCond %{HTTPS_HOST} hogehoge\.jp
RewriteCond %{ENV:SuspectHardDoS} .+
RewriteRule .* - [R=503,L]
ErrorDocument 503 "503 Forbidden."
DoSIgnoreContentType  image|javascript|css
DoSIgnoreIpRange 127.0.0.1


ここでは、10秒間に100回のアクセスが来たら、503エラーを返して1時間(3600秒)その状態を維持します。
パラメータについては、こちらを参照してみてください。
株式会社prophetさんのSTAFF BLOG

/var/log/httpd/error_log にこんなログが出ます。

[Tue Jul 11 04:55:19 2017] [notice] dosdetector: 'XX.XX.XX.XX' is suspected as DoS attack! (counter: XX)

ちゃんとチューニングしましょうね。

8
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
13