我已经在负载均衡器注释中将“ nginx.ingress.kubernetes.io/enable-modsecurity”设置为true,但似乎不起作用。
负载均衡器是否需要其他配置?可以加载OWASP规则集吗?
Rancher版本是2.2.7。
如NGINX入口控制器documentation中所述,您必须在ConfigMap中启用ModSecurity模块才能使其正常工作,并且默认情况下它以recommended configuration的“仅检测”模式启动
至于OWASP规则集,您可以设置此注释:
nginx.ingress.kubernetes.io/enable-owasp-core-rules: "true"
或者您可以将其包括在nginx.ingress.kubernetes.io/modsecurity-snippet
批注中。请务必注意,这些注释不能一起使用,因为如果这样做,则仅会读取第二个注释(代码段)。
一个简单的例子是:
nginx.ingress.kubernetes.io/modsecurity-snippet: |
SecRuleEngine On
SecDebugLog /tmp/modsec_debug.log
Include /etc/nginx/owasp-modsecurity-crs/nginx-modsecurity.conf