サーバセキュリティ ufw, Fail2Ban

Docker Nginx コンテナ + Fail2ban

以下、ホストマシンと共有したDocker Nginxのログファイルを参照して、Fail2banによるルールをNginxコンテナに適用。

[nginx-http-auth]
enabled = true
port    = http,https
logpath = /xxx/xxx/container_logs/nginx/*access.log
maxretry = 5
bantime  = 3600

[nginx-bad-request]
enabled  = true
port     = http,https
logpath  = /xxx/xxx/container_logs/nginx/*access.log
maxretry = 5
bantime  = 3600

[nginx-botsearch]
enabled  = true
port     = http,https
logpath  = /xxx/xxx/container_logs/nginx/*access.log
maxretry = 5
bantime  = 3600

注) fail2banの設定を変更する場合は、下記の設定ファイルをコピーして編集するのではなく、*.localを拡張子として空のファイルを作成し設定変更するセクションのみを記述すること。

/etc/fail2ban/fail2ban.conf —> fail2ban.local
/etc/fail2ban/jail.conf —> jail.local