1
2
3
4
5
6
7
8
9
10
11
12
13
|
# 限制某路径仅特定 IP 可访问
SecRule REQUEST_URI "^/admin" "phase:1,deny,id:20001,msg:'Forbidden access to /admin',chain"
SecRule REMOTE_ADDR "!@ipMatch 192.168.1.100"
# 禁止某路径使用 GET 请求
SecRule REQUEST_URI "^/secure-action" "phase:1,deny,id:20002,msg:'GET not allowed here',chain"
SecRule REQUEST_METHOD "@streq GET"
# 仅允许特定 Referer 或 User-Agent 访问某路径
SecRule REQUEST_URI "^/api/private" "phase:1,deny,id:20003,msg:'Blocked non-authorized client',chain"
SecRule REQUEST_HEADERS:User-Agent "!@streq MyTrustedClient/1.0"
# 还可以在不同的location下单独设置启用不同规则,用以实现多元化
|