Files
deploy.stack/etc/fail2ban/jail.d/gitea-ssh.local
T
cnphpbb a13785c6e2 build(etc): 完善 Fail2ban 防爆破配置
- 将 SSH 封禁改为端口无关的 allports 策略
- 新增 Gitea SSH 双链防护和失败日志过滤器
- 补充公共策略、再犯封禁及部署验证文档
2026-11-08 23:37:44 +08:00

22 lines
1015 B
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Gitea 内置 SSH 服务(容器内监听 2222,宿主发布端口不固定)
#
# 日志路径必须稳定:默认的 docker json-file 路径内嵌容器 ID,
# 容器一重建就静默失效(fail2ban 不报错,只是再也不封)。
# 因此要求 Gitea 用 file 模式写到挂载卷,见 docs/gitea-fail2ban-app-ini.md。
[gitea-ssh]
enabled = true
filter = gitea-ssh
logpath = /var/lib/gitea/log/gitea.log
maxretry = 5
findtime = 10m
bantime = 1d
# 双 action:默认 nftables chain 只 hook input,而 Docker 对发布端口做 DNAT 后
# 走 forward 链,容器流量根本不经过 input。只挂 input 会出现「封禁列表里有 IP、
# 但攻击者照样能连容器端口」。
# 第二条把同一条黑名单再挂到 forward,priority -10 早于 Docker 的
# table ip filter FORWARD(priority 0),确保先于 docker 规则丢弃。
action = nftables[type=allports]
nftables[type=allports, table=f2b-fwd, chain=f2b-fwd-chain, chain_hook=forward, chain_priority=-10]