很多人(我想)我在我的apache日志中发现了很多未经授权的访问我的网络服务器的尝试。在找到的URL模式中,每次都有类似“/ phpmyadmin”的东西。
因为这是为了避免在我的服务器中找不到的东西,我想要做的是:“如果有人试图访问phpMyAdmin
将其IP列入黑名单而不再惹恼我”
有人知道如何使用Apache或其他软件吗?
Thanx提前!
答案 0 :(得分:1)
可能会对你有帮助。
1)在/etc/fail2ban/filter.d/myapachejail.conf中创建一个过滤器
[INCLUDES]
before = common.conf
[Definition]
failregex = ^.* <HOST> -.*"(:?GET|POST|HEAD) \/(?:\/|)(?:w00tw00t\.at.*|phpMyAdmin.*|whatever.*|anotherone.*\..*)".*
ignoreregex =
2)更新你的/etc/fail2ban/jail.local,包括这个jail
banaction = iptables-multiport
action_mwl = %(banaction)s[name=%(__name__)s, port="%(port)s", protocol="%(protocol)s", chain="%(chain)s"]
%(mta)s-whois-lines[name=%(__name__)s, dest="%(destemail)s", logpath=%(logpath)s, chain="%(chain)s", sendername="%(sendername)s"]
[apachejail]
enabled = true
port = http,https
filter = myapachejail
logpath = /var/log/apache2/other_vhosts_access.log #<=== THIS MUST BE YOUR LOG FILE
maxretry = 1 # 1: Paranoid mode, 2: Heavy filter, 5: Ban any scanner
action = %(action_mwl)
3)检查您的过滤器regexp是否与任何日志条目匹配
sudo fail2ban-regex /var/log/apache2/other_vhosts_access.log /etc/fail2ban/filter.d/myapachejail.conf
Result:
Lines: 6160 lines, 0 ignored, 108 matched, 6052 missed
4)验证你找到/etc/fail2ban/action.d/iptables-multiport.conf
5)重启fail2ban服务
sudo service fail2ban restart
6)检查你的新监狱是否正在运行:
sudo fail2ban-client status
Status
|- Number of jail: 5
`- Jail list: myapachejail,xxxxx,xxx,xxxxx,xxxx
7)检查fail2ban日志
sudo vim /var/log/fail2ban.log
2014-07-07 07:32:20,926 fail2ban.actions:警告[myapachejail] Ban 198.20.69.74 2014-07-07 08:45:36,153 fail2ban.actions:警告[myapachejail]禁止116.10.191.223
7)检查你的iptables是否禁止:
sudo iptables -L -n
REJECT all -- 198.20.69.74 0.0.0.0/0 reject-with icmp-port-unreachable
REJECT all -- 116.10.191.223 0.0.0.0/0 reject-with icmp-port-unreachable
答案 1 :(得分:0)
可能的答案似乎是具有特定配置的 Fail2ban 。 我找到了一篇详细解释的帖子:How to protect Apache with Fail2ban。 如果有人有另一个有趣的解决方案,请告诉我们。