【问题标题】:ModSecurity default action when no rule is match?没有规则匹配时的 ModSecurity 默认操作?
【发布时间】:2021-12-21 03:13:11
【问题描述】:

我是使用 nginx 的 modSecurity 实验室,我有一个问题

如何为 actione 不匹配任何规则设置默认操作

例如,我有一组规则允许人们从一组 IP 做事,我想阻止所有其他请求? 我该怎么做?

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
SecGeoLookupDb /usr/local/geo/data/GeoLiteCity.dat

SecRule REMOTE_ADDR "@geoLookup" "phase:1,chain,id:10,allow,log,msg:'Blocking Country IP Address'"
SecRule GEO:COUNTRY_CODE "@pm CN"

SecDefaultAction "phase:1,log,auditlog,drop,status:403,tag:'SLA 24/7'"

【问题讨论】:

    标签: web-application-firewall mod-security2


    【解决方案1】:

    如果您想拒绝之前没有与任何规则匹配的所有请求,您必须在规则集的末尾创建一个明确的无条件规则 (SecAction),如下所示:

    SecAction "id:10001,phase:1,deny,status:403,log"
    

    请注意,使用此解决方案(phase:1 中的规则)您不能使用任何其他阶段。当然,你应该把这条规则放到phase:2中,但是在那个阶段没有任何规则就足够了。

    您的示例的更多注释:

    • 您的操作是 allow,但消息是阻止国家/地区 IP 地址,这有点令人困惑
    • 如果你只想控制访问/不访问国家/地区,有一个独立的Nginx module,你不需要任何WAF

    【讨论】:

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