【问题标题】:regex fail2ban rules正则表达式 fail2ban 规则
【发布时间】:2017-12-11 04:21:01
【问题描述】:

我正在我的服务器上设置 Fail2ban,最近有很多不良机器人正在抓取我的网站,导致我的 SQL 服务器停机

来自我的 Apache2 日志

51.255.65.13 - - [10/Dec/2017:12:03:19 +0800] "GET /crew/nm0935095-gary-winick HTTP/1.0" 200 17985 "-" "Mozilla/5.0 (compatible; AhrefsBot/5.2; +http://ahrefs.com/robot/)"
51.255.65.30 - - [10/Dec/2017:12:03:31 +0800] "GET /movie/tt0498567-summer-time-machine-blues HTTP/1.0" 200 17658 "-" "Mozilla/5.0 (compatible; AhrefsBot/5.2; +http://ahrefs.com/robot/)"
217.182.132.190 - - [10/Dec/2017:12:03:36 +0800] "GET /movie/tt1705064-genji-monogatari:-sennen-no-nazo/ HTTP/1.0" 200 17344 "-" "Mozilla/5.0 (compatible; AhrefsBot/5.2; +http://ahrefs.com/robot/)"

如何为“ahrefs.com”创建一个失败的正则表达式?

非常感谢

【问题讨论】:

  • 你不想要fail2ban,你想要Apache规则拒绝引荐来源。一个简单的Apache deny referrer 谷歌搜索将显示有关该主题的大量资源。
  • 谢谢,这是暂时的,但我检查了日志,在出现几个 500 错误后机器人仍在工作,它仍在抓取我的网站:(

标签: regex fail2ban


【解决方案1】:

为了捕获包含“ahrefs.com”的任何内容,您的失败正则表达式应如下所示:

failregex = ^<HOST>.*ahrefs\.com.*

其中&lt;HOST&gt;标签是内置Fail2ban作为(?:::f{4,6}:)?(?P&lt;host&gt;\S+)的别名:

https://www.fail2ban.org/wiki/index.php/Apache

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多