概要
前回の続きです
なぜか nginx も network_mode: host にしていたので nginx は docker ネットワーク上で動作させます
環境
- Ubuntu 24.04
- docker
- linuxserver/fail2ban 1.1.0-r2-ls26
- fail2ban 1.1.0
修正箇所
- jail.local の chain を DOCKER-USER に変更
- nginx コンテナの network_mode を削除し ports でバインドするように変更
前回からの差分
diff --git a/compose.yaml b/compose.yaml
index 1f4124c..7a8a33f 100644
--- a/compose.yaml
+++ b/compose.yaml
@@ -2,7 +2,9 @@ services:
nginx:
image: nginx:latest
container_name: nginx
- network_mode: host
+ ports:
+ - "80:80"
+ - "443:443"
volumes:
- ./nginx/log:/var/log/nginx # このログをfail2banで監視
restart: unless-stopped
diff --git a/config/jail.local b/config/jail.local
index 82c38b7..3e40cb0 100644
--- a/config/jail.local
+++ b/config/jail.local
@@ -78,7 +78,7 @@ action = %(action_)s
[nginx-404]
# Custom filter to detect excessive 404 errors
enabled = true
-chain = INPUT
+chain = DOCKER-USER
port = http,https
filter = nginx-404
logpath = /remotelogs/nginx/access.log
最後に
chain は iptables の chain に紐づいています
なぜ最初からこうしなかったのだろうか
0 件のコメント:
コメントを投稿