你可以在这里做很多事情。
By default a regex is used to match in ModSecurity 这样您就可以编写一条规则来覆盖两个 URI 并在不匹配时阻止:
SecRule REQUEST_URI "!\/(configuration|update)\/" "phase:1,id:700003,block
您也可以使用@pm:
SecRule REQUEST_URI "!@pm \/configuration\/ \/update\/" "phase:1,id:700003,block
或者,您可以使用skipAfter,它允许您在不同的规则中列出 URL,然后有一个阻止规则,如果前面的任何规则匹配,则会跳过该规则:
SecMarker BEGIN_VALID_URL_CHECK
SecRule REQUEST_URI "!@beginsWith /configuration" \ "id:700003, phase:1,log,skipAfter:END_VALID_URL_CHECK,msg:'Different URL Accessed'"
SecRule REQUEST_URI "@beginsWith /update" \ "id:700004, phase:1,log,skipAfter:END_VALID_URL_CHECK,msg:'Update URI accessed'"
SecRule REQUEST_URI "." \ "id:700005, phase:1,log,block,msg:'Another URI accessed - blocking'"
SecMarker END_VALID_URL_CHECK
或者,您可以allow 匹配那些在 ModSecurity 中停止处理此请求的模式的规则(这可能是一个不好的选择,因为它会跳过稍后在您的配置中定义的任何其他 ModSecurity 规则,但为了完整性我将其包括在内清酒):
SecRule REQUEST_URI "!@beginsWith /configuration" \ "id:700003, phase:1,log,allow,msg:'Different URL Accessed'"
SecRule REQUEST_URI "@beginsWith /update" \ "id:700004, phase:1,log,allow, msg:'Update URI accessed'"
SecRule REQUEST_URI "." \ "id:700005, phase:1,log,block, msg:'Another URI accessed - blocking'"