- Disable Nginx Server Tokens: Suppress server version disclosure in HTTP headers.
- Buffer Overflow Defense: Restrict client_body_buffer_size and client_max_body_size.
- Rate Limiting: Implement limit_req_zone to mitigate HTTP flood attacks.
- TLS 1.3 Strict Ciphers: Mandate ECDHE-ECDSA-AES128-GCM-SHA256 and modern TLS protocols.
1. Disabling Server Tokens & Information Disclosure
By default, Nginx broadcasts its exact version number in HTTP response headers and 40x/50x error pages (e.g., Server: nginx/1.24.0). Attackers use this version information to query public CVE databases for unpatched vulnerabilities.
Suppressing server tokens is the first step in reducing information leakage across public endpoints:
# Place inside /etc/nginx/nginx.conf http block
server_tokens off;
more_clear_headers Server;
2. Mitigating HTTP Floods via Rate Limiting Zones
Layer 7 HTTP flood attacks attempt to exhaust Nginx worker connections. Configuring rate-limiting zones using limit_req_zone enforces request thresholds per IP address:
# Define rate limit zone in http context
limit_req_zone $binary_remote_addr zone=one:10m rate=10r/s;
# Apply to server location context
location / {
limit_req zone=one burst=20 nodelay;
proxy_pass http://127.0.0.1:8080;
}
Frequently Asked Questions (FAQ)
What is the difference between limit_req and limit_conn in Nginx?
limit_req limits the rate of incoming HTTP requests per second, while limit_conn limits the total number of simultaneous active TCP connections per IP.
Utility Security Tools Related to this Article:
Gunakan Secure Password Generator dan Diff Checker untuk membantu alur kerja konfigurasi keamanan Anda secara privasi di browser.