feat(security): 添加fail2ban集成防止暴力破解登录
- 新增fail2ban过滤器和监狱配置文件 - 修改登录视图记录客户端IP和认证失败日志 - 更新日志配置添加syslog处理器用于fail2ban检测 - 在README中添加fail2ban配置和使用文档
This commit is contained in:
20
deploy/fail2ban/filter.d/diary-family.conf
Normal file
20
deploy/fail2ban/filter.d/diary-family.conf
Normal file
@@ -0,0 +1,20 @@
|
||||
# Fail2Ban filter for diary-family Django application
|
||||
# 用于检测家庭日报系统登录失败的规则
|
||||
|
||||
[Definition]
|
||||
|
||||
# 匹配登录失败的日志行
|
||||
# 日志格式: django.security.login: WARNING Authentication failure for username: xxx from IP: xxx.xxx.xxx.xxx
|
||||
failregex = ^.*Authentication failure for username: .* from IP: <HOST>.*$
|
||||
|
||||
# 可选:匹配其他认证失败模式(如被禁用的用户)
|
||||
# failregex = ^%(__prefix_line)s.*Authentication failure for username: .* from IP: <HOST>.*$
|
||||
# ^%(__prefix_line)s.*Invalid login attempt from IP: <HOST>.*$
|
||||
|
||||
# 忽略正则(可选)
|
||||
# ignoreregex =
|
||||
|
||||
[Init]
|
||||
|
||||
# 日期格式(如果需要)
|
||||
# datepattern = %%Y-%%m-%%d %%H:%%M:%%S
|
||||
Reference in New Issue
Block a user