咱们须要在咱们网站中防止密码的暴利破解。Fail2Ban 是一个 Python 的应用来查看日志文件,使用的是正则表达式,同时还能够与Shorewall (或者 iptables)直接工做来来启用临时黑名单。当必定的密码破解规则被使用后,就可使用上面的方法了。咱们能够用这个来限制给定的 URL 来访问 Confluence 的登陆界面的次数。php
本列表是安装的核心部分:python
/etc/fail2ban
.conf
文件(fail2ban.conf
和 jail.conf)。请不要对这个进行修改,若是你进行修改的话,将会致使升级的时候困难。
.conf
文件中的配置进行合并。这个文件只会对你须要的修改部分进行修改,可以让你的维护更加容易和简单。filter.d
中进行定义 — 在这里这里,你能够定义正则表达式,每一个正则表达式进入本身的文件。action.d
文件中定义 — 你可能不须要添加一个,可是你知道在那里进行定义的可以帮你更好的找到问题。jail.conf
and jail.local
中定义的。不要忘记了为每个都启动设置 — 这个有可能致使错误的启用,正确的却没有启用。/etc/init.d/fail2ban {start|stop|status
} 来进行进程相关的操做fail2ban-client -d
来导出当前的配置到 STDOUT。在你对问题进行查看的时候,这个就很是有帮助。jail.local正则表达式
# The DEFAULT allows a global definition of the options. They can be override # in each jail afterwards. [DEFAULT] # "ignoreip" can be an IP address, a CIDR mask or a DNS host. Fail2ban will not # ban a host which matches an address in this list. Several addresses can be # defined using space separator. # ignoreip = <space-separated list of IPs> # "bantime" is the number of seconds that a host is banned. bantime = 600 # A host is banned if it has generated "maxretry" during the last "findtime" # seconds. findtime = 60 # "maxretry" is the number of failures before a host get banned. maxretry = 3 [ssh-iptables] enabled = false [apache-shorewall] enabled = true filter = cac-login action = shorewall logpath = /var/log/httpd/confluence-access.log bantime = 600 maxretry = 3 findtime = 60 backend = polling
下面仅仅被用来做为示例,你须要根据你的站点调整。express
filter.d/confluence-login.confapache
[Definition] failregex = <HOST>.*"GET /login.action ignoreregex =
https://www.cwiki.us/display/CONF6ZH/Using+Fail2Ban+to+limit+login+attemptsssh