LoginSignup
3
4

More than 5 years have passed since last update.

【手順】DOS対策(mod_evasive)

Last updated at Posted at 2017-03-03

DOS対策手順(mod_evasive)

前提条件

  • 検証OS: CentOS7
  • アパッチバージョン: httpd24u
  • アパッチが既にインストールされていること

手順

  1. 対象サーバーにログインして、rootにsu

  2. モジュールの確認

# httpd -l
Compiled in modules:  
 core.c
 mod_so.c           ←これがあることを確認。ない場合はhttpd24u-develをインストールする
 http_core.c

# httpd -M | grep evasive
evasive20_module (shared)  ←これがないことを確認。ある場合はすでにDOS対策設定されている可能性高

3.epelからmod_evasiveをインストールする。

# yum install epel-release
# yum install --enablerepo=epel mod_evasive

4.任意のDOS設定を行う。

# vi /etc/httpd/conf.d/mod_evasive
DOSHashTableSize    3097                          ←各子プロセスでのハッシュテーブルサイズ。大きくするとパフォーマンス向上するが、メモリを消費する。
DOSPageCount        2                             ←同ページへのリクエスト数のしきい値
DOSSiteCount        50                             ←同サイトへのリクエスト数のしきい値
DOSPageInterval     1                             ←PageCountしきい値の計測間隔(秒)
DOSSiteInterval     1                             ←SiteCountしきい値の計測間隔(秒)
DOSBlockingPeriod   10                            ←IPアドレスを遮断する時間(秒) 遮断されている時間は403 (Forbidden)を返す。
DOSLogDir           "/var/lock/mod_evasive"  ←ログの排出先
#DOSWhitelist   127.0.0.1                         ←検出対象外とするIPアドレス

5.Apacheの再起動

# systemctl restart httpd

6.モジュールの確認

# httpd -M | grep evasive
evasive20_module (shared)  ←これがあることを確認。

7.動作確認

# cd /usr/share/doc/mod_evasive-1.10.1
# chmod +x test.pl
# perl test.pl               ←実行結果が「200 OK」から、途中で「403 Forbidden」になれば完了。
HTTP/1.1 200 OK
HTTP/1.1 200 OK
HTTP/1.1 200 OK
HTTP/1.1 200 OK
HTTP/1.1 403 Forbidden
HTTP/1.1 403 Forbidden
HTTP/1.1 403 Forbidden
HTTP/1.1 403 Forbidden

参考

http://dev.classmethod.jp/cloud/aws/mod_evasive20/
http://www.frontier-line.org/lognote/?p=2884
http://makizou.com/1341/

3
4
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
3
4