From afebcd6658681b2053bc54c6c9a180597937941c Mon Sep 17 00:00:00 2001 From: Robert Gingras Date: Thu, 23 Jul 2026 13:20:34 -0400 Subject: [PATCH] fix(agent): remove ModSecurity, raise HTTP/2 and HTTP/3 upload buffers ModSecurity ran in DetectionOnly mode, so every request body was buffered and scanned on the agent without blocking anything, defeating proxy_request_buffering off and crippling large-upload throughput. Remove it entirely: - nginx directives in the agent config template - libnginx-mod-http-modsecurity / modsecurity-crs package dependencies - agent image build steps and vendored CRS configuration files - the custom nginx logrotate override, which only existed to keep modsec_audit.log out of the stock glob and copytruncate it around owasp-modsecurity/ModSecurity-nginx#351; the Debian default (/var/log/nginx/*.log, same policy) now covers everything - WAF wording on the 403 error page and in the docs Raise the HTTP/2 and HTTP/3 request-body buffers from their small defaults (64k preread / h3 stream buffer, 256k h2 recv buffer) so multiplexed uploads are not throttled by flow control. The h2 recv buffer is per worker, so it is sized at several prereads to keep concurrent uploads from starving each other: http2_body_preread_size 4m; http2_recv_buffer_size 16m; http3_stream_buffer_size 4m; Fixes #395 --- agent/.fpm | 2 - agent/templates/nginx.conf.ejs | 16 +- error-pages/403.html | 19 +- images/agent/Dockerfile | 20 +- ...ESPONSE-999-EXCLUSION-RULES-AFTER-CRS.conf | 86 -- images/agent/crs-setup.conf | 882 ------------------ images/agent/nginx.logrotate | 32 - .../docs/developers/docker-images.md | 4 +- 8 files changed, 23 insertions(+), 1038 deletions(-) delete mode 100644 images/agent/RESPONSE-999-EXCLUSION-RULES-AFTER-CRS.conf delete mode 100644 images/agent/crs-setup.conf delete mode 100644 images/agent/nginx.logrotate diff --git a/agent/.fpm b/agent/.fpm index 50e677dc..f7646757 100644 --- a/agent/.fpm +++ b/agent/.fpm @@ -9,8 +9,6 @@ --depends nodejs --depends nginx --depends libnginx-mod-stream ---depends libnginx-mod-http-modsecurity ---depends modsecurity-crs --depends ssl-cert --depends dnsmasq --deb-no-default-config-files diff --git a/agent/templates/nginx.conf.ejs b/agent/templates/nginx.conf.ejs index dad4b500..5238054c 100644 --- a/agent/templates/nginx.conf.ejs +++ b/agent/templates/nginx.conf.ejs @@ -43,9 +43,17 @@ http { proxy_cache_path /var/cache/nginx/auth_cache levels=1:2 keys_zone=auth_cache:1m max_size=10m inactive=5m; - modsecurity on; - modsecurity_rules_file /etc/nginx/modsecurity_includes.conf; - modsecurity_transaction_id "$request_id"; + <%_ /* + Upload throughput over HTTP/2 and HTTP/3. The small defaults (64k body + preread / h3 stream buffer, 256k per-worker h2 recv buffer) cap how much + request body a client may send before waiting on flow control, which + throttles large uploads through the proxy. The recv buffer is shared per + worker, so it is sized at several prereads to keep concurrent uploads + from starving each other. + */ -%> + http2_body_preread_size 4m; + http2_recv_buffer_size 16m; + http3_stream_buffer_size 4m; <%_ /* Modern TLS configuration */ -%> ssl_protocols TLSv1.2 TLSv1.3; @@ -68,7 +76,6 @@ http { Internal error page server on a unix socket. Named locations proxy here with proxy_method GET so that NGINX's static file module will serve the HTML regardless of the original request method (POST, PUT, etc.). - ModSecurity is disabled to prevent re-evaluation of the original request. */ -%> upstream error_pages { server unix:/run/nginx-error-pages.sock; @@ -76,7 +83,6 @@ http { server { listen unix:/run/nginx-error-pages.sock; - modsecurity off; ssi on; root /opt/opensource-server/error-pages; diff --git a/error-pages/403.html b/error-pages/403.html index f0c20d76..2967f5af 100644 --- a/error-pages/403.html +++ b/error-pages/403.html @@ -3,7 +3,7 @@ - 403 — Request Blocked + 403 — Access Denied