Nginx runs on millions of servers — and most ship with default configuration. These 6 settings turn your Nginx into a hardened reverse proxy that reveals no unnecessary information and actively protects against attacks. 01 — Hide Version: server_tokens off By default, Nginx sends its version number in every HTTP response header. Attackers use this for targeted exploits against known versions. http { server_tokens off; } sudo nginx -t && sudo systemctl reload nginx curl -I https://your-domain.com | grep Server # Should now show: Server: nginx (no version) 02 — Security Headers: HSTS, X-Frame, X-Content-Type server { add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; add_header X-Frame-Options "SAMEORIGIN" always; add_header X-Content-Type-Options "nosniff" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always; add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always; } curl -I https://your-domain.com | grep -E "Strict|X-Frame|X-Content" # Check grade: https://securityheaders.com/ 03 — Rate Limiting: Stop Login Brute-Force http { limit_req_zone $binary_remote_addr zone=login:10m rate=5r/s; limit_req_zone $binary_remote_addr zone=api:10m rate=30r/s; } server { location /api/auth/login { limit_req zone=login burst=10 nodelay; limit_req_status 429; proxy_pass http://127.0.0.1:8000; } } 04 — Block .env and .git Use return 404 instead of deny all — a 403 reveals the file exists, a 404 does not. server { location ~ /\.(?!well-known) { return 404; } location ~* \.(env|log|bak|sql|conf|yaml|yml|ini)$ { return 404; } } curl -o /dev/null -w "%{http_code}" https://your-domain.com/.env # Expected: 404 05 — Modern SSL: TLS 1.2/1.3 + Mozilla Ciphers server { listen 443 ssl; listen [::]:443 ssl; http2 on; ssl_certificate /etc/letsencrypt/live/your-domain.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem; ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384; ssl_prefer_server_ciphers off; ssl_session_cache shared:SSL:10m; ssl_session_timeout 1d; ssl_session_tickets off; ssl_stapling on; ssl_stapling_verify on; ssl_trusted_certificate /etc/letsencrypt/live/your-domain.com/chain.pem; resolver 8.8.8.8 8.8.4.4 valid=300s; resolver_timeout 5s; } 06 — Force HTTPS: 301 Redirect from Port 80 server { listen 80; listen [::]:80; server_name your-domain.com; location /.well-known/acme-challenge/ { root /var/www/certbot; } location / { return 301 https://$host$request_uri; } } curl -I http://your-domain.com # Expected: # HTTP/1.1 301 Moved Permanently # Location: https://your-domain.com/ Checklist ✅ server_tokens off — Nginx version hidden from headers ✅ HSTS, X-Frame-Options, X-Content-Type-Options, Referrer-Policy set ✅ Rate limiting on login and API endpoints ✅ .env , .git , config files return 404 ✅ Only TLS 1.2/1.3, weak ciphers disabled, OCSP stapling active ✅ Port 80 permanently redirects (301) to HTTPS These 6 settings take under 30 minutes to implement. Combined with the Linux server hardening guide , you have a solid security foundation for any production server.