Apache httpd : mod_evasive を利用する2024/02/02 |
|
[mod_evasive] モジュールを有効にして、DoS アタック対策を設定します。 |
|
| [1] | [mod_evasive] をインストールして設定します。 |
|
root@www:~ #
pkg install -y ap24-mod_evasive
root@www:~ #
vi /usr/local/etc/apache24/httpd.conf # 184 : コメント解除 LoadModule evasive20_module libexec/apache24/mod_evasive20.so
root@www:~ #
vi /usr/local/etc/apache24/Includes/evasive.conf # 新規作成
<IfModule mod_evasive20.c>
# ハッシュテーブルサイズ : 値の大きさに応じてパフォーマンス向上 & メモリー消費増
DOSHashTableSize 3097
# 同一ページへの DOSPageInterval (以下で設定) 秒あたりのリクエスト数のしきい値
DOSPageCount 2
# 同一サイトの DOSSiteInterval (以下で設定) 秒あたりのリクエスト数のしきい値
DOSSiteCount 50
# DOSPageCount の間隔 (秒)
DOSPageInterval 1
# DOSSiteCount の間隔 (秒)
DOSSiteInterval 1
# リクエスト数がしきい値を超えた場合にアクセスをブロックする時間 (秒)
DOSBlockingPeriod 10
# ログ保管ディレクトリ
DOSLogDir "/var/log/mod-evasive"
# 必要に応じてコメント解除して設定
# ブロックした際に設定したメールアドレスへ通知
#DOSEmailNotify root@localhost
# 任意の実行したいコマンドを設定可
#DOSSystemCommand "su - someuser -c '/sbin/... %s ...'"
</IfModule>
mkdir /var/log/mod-evasive root@www:~ # chown www:www /var/log/mod-evasive root@www:~ # service apache24 reload |
| [2] | Apache httpd に連続アクセスして動作確認します。 |
|
root@www:~ # for i in `seq 1 20`; do curl -I localhost; done HTTP/1.1 200 OK Date: Fri, 02 Feb 2024 01:01:38 GMT Server: Apache/2.4.58 (FreeBSD) OpenSSL/3.0.12 mod_auth_kerb/5.4 Upgrade: h2 Connection: Upgrade Last-Modified: Tue, 30 Jan 2024 00:21:58 GMT ETag: "82-6101ec01fa41e" Accept-Ranges: bytes Content-Length: 130 Content-Type: text/html HTTP/1.1 200 OK Date: Fri, 02 Feb 2024 01:01:38 GMT Server: Apache/2.4.58 (FreeBSD) OpenSSL/3.0.12 mod_auth_kerb/5.4 Upgrade: h2 Connection: Upgrade Last-Modified: Tue, 30 Jan 2024 00:21:58 GMT ETag: "82-6101ec01fa41e" Accept-Ranges: bytes Content-Length: 130 Content-Type: text/html HTTP/1.1 200 OK Date: Fri, 02 Feb 2024 01:01:38 GMT Server: Apache/2.4.58 (FreeBSD) OpenSSL/3.0.12 mod_auth_kerb/5.4 Upgrade: h2 Connection: Upgrade Last-Modified: Tue, 30 Jan 2024 00:21:58 GMT ETag: "82-6101ec01fa41e" Accept-Ranges: bytes Content-Length: 130 Content-Type: text/html HTTP/1.1 200 OK Date: Fri, 02 Feb 2024 01:01:38 GMT Server: Apache/2.4.58 (FreeBSD) OpenSSL/3.0.12 mod_auth_kerb/5.4 Upgrade: h2 Connection: Upgrade Last-Modified: Tue, 30 Jan 2024 00:21:58 GMT ETag: "82-6101ec01fa41e" Accept-Ranges: bytes Content-Length: 130 Content-Type: text/html HTTP/1.1 403 Forbidden Date: Fri, 02 Feb 2024 01:01:38 GMT Server: Apache/2.4.58 (FreeBSD) OpenSSL/3.0.12 mod_auth_kerb/5.4 Content-Type: text/html; charset=iso-8859-1 HTTP/1.1 403 Forbidden Date: Fri, 02 Feb 2024 01:01:38 GMT Server: Apache/2.4.58 (FreeBSD) OpenSSL/3.0.12 mod_auth_kerb/5.4 Content-Type: text/html; charset=iso-8859-1 HTTP/1.1 403 Forbidden Date: Fri, 02 Feb 2024 01:01:38 GMT Server: Apache/2.4.58 (FreeBSD) OpenSSL/3.0.12 mod_auth_kerb/5.4 Content-Type: text/html; charset=iso-8859-1 ..... ..... # ログを設定した場合は 指定尾所へ記録される root@www:~ # ls -l /var/log/mod-evasive total 1 -rw-r--r-- 1 www www 5 Feb 2 09:59 dos-::1 |
| Sponsored Link |
|
|