From 2839e6f7a9268c2155031831ef498c2376f82148 Mon Sep 17 00:00:00 2001 From: RAM PRASAD ATLURI <116977270+ATLURI0001@users.noreply.github.com> Date: Mon, 9 Nov 2026 11:37:38 +0530 Subject: [PATCH] perf(edge): enable gzip compression and configure client request buffer limits - Configured gzip compression (level 5, min_length 256 bytes) across text, JSON, and XML MIME types to reduce edge egress bandwidth and latency. - Set explicit client body (128k) and header buffer (1k default, 4x8k large) thresholds to prevent memory fragmentation and slowloris vector expansion. - Added automated unit test coverage in tests/test_project.py. --- nginx/nginx.conf | 11 +++++++++++ tests/test_project.py | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/nginx/nginx.conf b/nginx/nginx.conf index 6a3c3ee..6a5a962 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -16,6 +16,17 @@ http { keepalive_timeout 65; server_tokens off; client_max_body_size 10m; + client_body_buffer_size 128k; + client_header_buffer_size 1k; + large_client_header_buffers 4 8k; + + # Compression configuration for bandwidth and latency efficiency + gzip on; + gzip_vary on; + gzip_proxied any; + gzip_comp_level 5; + gzip_min_length 256; + gzip_types application/javascript application/json application/xml text/css text/plain text/xml; # Log the upstream destination and timing; no request bodies or credentials. log_format edge '$remote_addr - $request_method $uri $status ' diff --git a/tests/test_project.py b/tests/test_project.py index 09b094d..eecc99f 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -96,5 +96,15 @@ def test_compose_healthchecks_and_isolation(self): self.assertIn('GF_USERS_ALLOW_SIGN_UP: "false"', compose) self.assertIn('--nginx.scrape-uri=http://edge:8081/stub_status', compose) + def test_gzip_compression_and_buffer_tuning(self): + cfg = load('nginx/nginx.conf') + self.assertIn('gzip on;', cfg) + self.assertIn('gzip_vary on;', cfg) + self.assertIn('gzip_comp_level 5;', cfg) + self.assertIn('gzip_min_length 256;', cfg) + self.assertIn('application/json', cfg) + self.assertIn('client_body_buffer_size 128k;', cfg) + self.assertIn('large_client_header_buffers 4 8k;', cfg) + if __name__ == '__main__': unittest.main()