Skip to content

Commit

Permalink
Merge pull request #4091 from weltschraet/modsecurity-memory
Browse files Browse the repository at this point in the history
reduce memory footprint and cpu usage when modsecurity and owasp rule…
  • Loading branch information
k8s-ci-robot authored May 19, 2019
2 parents 19501b2 + abca32b commit ff80dca
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion rootfs/etc/nginx/template/nginx.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,17 @@ http {
{{ end }}
{{ end }}

{{ if $all.Cfg.EnableModsecurity }}
modsecurity on;

modsecurity_rules_file /etc/nginx/modsecurity/modsecurity.conf;

{{ if $all.Cfg.EnableOWASPCoreRules }}
modsecurity_rules_file /etc/nginx/owasp-modsecurity-crs/nginx-modsecurity.conf;
{{ end }}

{{ end }}

{{ if $cfg.UseGeoIP }}
{{/* databases used to determine the country depending on the client IP address */}}
{{/* http://nginx.org/en/docs/http/ngx_http_geoip_module.html */}}
Expand Down Expand Up @@ -1102,15 +1113,17 @@ stream {
set $proxy_host $proxy_upstream_name;

{{ if (or $location.ModSecurity.Enable $all.Cfg.EnableModsecurity) }}
{{ if not $all.Cfg.EnableModsecurity }}
modsecurity on;

modsecurity_rules_file /etc/nginx/modsecurity/modsecurity.conf;
{{ end }}

{{ if $location.ModSecurity.Snippet }}
modsecurity_rules '
{{ $location.ModSecurity.Snippet }}
';
{{ else if (or $location.ModSecurity.OWASPRules $all.Cfg.EnableOWASPCoreRules) }}
{{ else if (and ((not $all.Cfg.EnableOWASPCoreRules) $location.ModSecurity.OWASPRules))}}
modsecurity_rules_file /etc/nginx/owasp-modsecurity-crs/nginx-modsecurity.conf;
{{ end }}

Expand Down

0 comments on commit ff80dca

Please sign in to comment.