Mod 违反 Apache 配置测试的安全规则

Mod security rule breaking Apache configtest

我正在尝试添加 mod 安全规则,以对由 apache 提供服务的 Web 应用程序上的特定 uri 实施速率限制。

尝试重新启动 apache 时出现以下错误:

ModSecurity: No action id present within the rule
Action 'configtest' failed.
The Apache error log may have more information

具体来说——这就是我要实现的目标:https://johnleach.co.uk/words/2012/05/15/rate-limiting-with-apache-and-mod-security/

这篇文章似乎是为 mod_security 的早期版本编写的,其中不需要 ID。

不过,我修改了规则以包含一个 id(如您所见,我添加了 id:1234)。因此我不确定为什么我仍然收到错误。

<LocationMatch "^/login_check">
  SecAction initcol:ip=%{REMOTE_ADDR},pass,nolog
  SecAction "phase:5,deprecatevar:ip.somepathcounter=1/1,pass,nolog"
  SecRule IP:SOMEPATHCOUNTER "@gt 60" "phase:2,id:1234,pause:300,deny,status:509,setenv:RATELIMITED,skip:1,nolog"
  SecAction "phase:2,pass,setvar:ip.somepathcounter=+1,nolog"
  Header always set Retry-After "10" env=RATELIMITED
</LocationMatch>

不太确定如何调试它。欢迎任何意见。

SecAction 指令也需要一个 id:https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-%28v2.x%29#id

Note : The id action is required for all SecRule/SecAction directives as of v2.7.0

也为您的 SecAction 行添加一个唯一 ID,它应该可以工作。