About nginx config generator
Nginx is a popular web server and reverse proxy. A server block defines which domain it answers for and what it does with requests.
Common setups
- Static site with a root directory.
- Single-page app with fallback to index.html.
- Reverse proxy to a Node, Python or PHP app.
After editing
- Run nginx -t to test the configuration.
- Reload with nginx -s reload or systemctl reload nginx.
- Add HTTPS with a free Let's Encrypt certificate.
A worked example
A reverse proxy block listens on port 80 for example.com, passes requests to http://127.0.0.1:3000 and sets the Host and X-Forwarded-For headers so the app sees real client details. After testing with nginx -t, reload and add HTTPS with Certbot.
Performance and safety
- Enable gzip or Brotli for text responses.
- Set long cache times for fingerprinted static files.
- Redirect HTTP to HTTPS and add security headers.
