Nginx Config Update Checklist and Summary Complete Guide for Node.js
A complete checklist and summary for updating Nginx configuration in your Node.js deployment all the changes you'll need and when to make them.
Nginx Config Update Checklist and Summary
This is a complete guide to all the Nginx config updates you'll need for your Node.js application.
Updates by Stage
Initial Deployment
- Create server block (listen 80, server_name)
- proxy_pass to localhost:3000
- proxy_set_header Host, X-Real-IP, X-Forwarded-For, X-Forwarded-Proto
- Remove default site
- Test and reload
Adding SSL
- Install certbot
- Run certbot --nginx -d yourdomain.com
- Verify HTTPS works
- Set up auto-renewal (certbot renew --dry-run)
Adding WebSocket (Socket.io)
- Add /socket.io/ location block
- Add proxy_http_version 1.1
- Add Upgrade and Connection headers
- Set proxy_read_timeout 86400s
Adding Frontend (Static Files)
- Add server block for frontend domain
- Set root to build directory
- Add try_files $uri $uri/ /index.html
- Add static file caching (expires 1y)
Performance Updates
- Enable gzip compression
- Cache static files
- Set worker_processes auto, worker_connections 2048
- Enable keep-alive
- Enable HTTP/2
- Add proxy buffering
- Disable access_log for static files
Security Updates
- Add security headers (HSTS, X-Frame-Options, CSP)
- Set server_tokens off
- Add rate limiting
- Set client_max_body_size
- Block hidden files
- Add short timeouts (prevent slowloris)
- Restrict admin access by IP
Load Balancing
- Create upstream block
- Add ip_hash for WebSocket
- Add health checks (max_fails, fail_timeout)
- Add/remove instances as needed
The Update Process (Always)
# 1. Back up sudo cp /etc/nginx/sites-available/devtinder /etc/nginx/sites-available/devtinder.bak # 2. Edit sudo nano /etc/nginx/sites-available/devtinder # 3. Test sudo nginx -t # 4. Reload (zero downtime) sudo systemctl reload nginx # 5. Verify sudo systemctl status nginx curl -I https://yourdomain.com sudo tail -5 /var/log/nginx/error.log # 6. Rollback if needed sudo cp /etc/nginx/sites-available/devtinder.bak /etc/nginx/sites-available/devtinder sudo nginx -t && sudo systemctl reload nginx
Common Update Scenarios
Add a New Subdomain
server { listen 443 ssl; server_name admin.yourdomain.com; location / { proxy_pass http://localhost:3001; } }
sudo certbot --nginx -d admin.yourdomain.com
Increase Rate Limit
limit_req_zone $binary_remote_addr zone=api:10m rate=20r/s; # Was 10r/s
Add a New Backend Instance
upstream backend { server 127.0.0.1:3000; server 127.0.0.1:3001; # New }
Change Upload Limit
client_max_body_size 20M; # Was 10M
The Takeaway
Nginx config updates are categorized by stage: initial deployment, SSL, WebSocket, frontend, performance, security, and load balancing. The update process is always the same: back up, edit, test (nginx -t), reload (zero downtime), verify, and rollback if needed. Version-control your config, automate with scripts, and document all changes. This ensures your Node.js deployment stays secure, performant, and available.
Always: back up the current config, edit the config, test with nginx -t, reload with systemctl reload nginx (zero downtime), verify with systemctl status and curl, and rollback if needed. Never skip the test step a syntax error could take down your entire app.
Initial: server block and proxy_pass. SSL: certbot --nginx. WebSocket: /socket.io/ block with Upgrade headers. Frontend: static files with try_files. Performance: gzip, caching, workers. Security: headers, rate limiting. Load balancing: upstream with ip_hash.
Add a new server block with server_name new.yourdomain.com and the appropriate location/proxy_pass. Get SSL with sudo certbot --nginx -d new.yourdomain.com. Test with nginx -t and reload. Ensure DNS A record for the subdomain points to your server.
Update the limit_req_zone rate (e.g., from rate=10r/s to rate=20r/s). Test with nginx -t and reload. This immediately applies the new rate to all new connections. Existing connections continue with the old rate until they reconnect.
Add a new line to the upstream block: server 127.0.0.1:3001. Start the Node.js instance on that port. Test with nginx -t and reload. Nginx automatically distributes traffic to the new instance. Use 'down' to temporarily remove an instance with zero downtime.
Ready to master Node.js completely?
Want to upskill yourself, crack your next interview, and get your dream job? Join our comprehensive course to dive deeper with high-quality video tutorials, solve interview questions, and a premium community.
Master Node.js
Want to upskill yourself, crack your next interview, and get your dream job? Join our comprehensive course.

