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()