nginx Config Generator
nginx server blocks for reverse proxy, static, SPA or PHP, with HTTPS.
About this tool
Enter your domain, choose the site type (reverse proxy, static, SPA or PHP) and tick the extras you want: HTTPS with the Let's Encrypt certificate paths, HTTPโHTTPS and www redirects, WebSocket support, gzip, static-asset caching and security headers. Copy or download the .conf file.
How the config is put together
For HTTPS the generator writes three server blocks: one on port 80 that 301-redirects everything to HTTPS, one that redirects www to the bare domain, and the main HTTPS server, using the certificate paths Certbot creates under /etc/letsencrypt/live/. A reverse proxy passes requests to your app (http://127.0.0.1:3000) with the Host, X-Real-IP, X-Forwarded-For and X-Forwarded-Proto headers that frameworks need to build correct URLs and log real client IPs. WebSocket support adds the Upgrade/Connection mapping and a long read timeout. A single-page app uses try_files โฆ /index.html, so client-side routes don't 404. PHP sites pass .php requests to PHP-FPM and block hidden files. Extras include gzip for text assets, 30-day immutable caching for fingerprinted CSS, JS, images and fonts, an upload size limit, server_tokens off, and nosniff, Referrer-Policy, X-Frame-Options and HSTS headers. Install it in sites-available or conf.d, run sudo nginx -t, then reload. Honest limits: get the certificate first (sudo certbot certonly or --nginx). The http2 on; directive needs nginx 1.25.1+, and a Content-Security-Policy is site-specific, so add it yourself. The CSP header generator, the HTTP headers analyzer and the systemd service generator are related.
Frequently asked questions
How do I set up nginx as a reverse proxy?
Choose Reverse proxy, enter your app's address (e.g. http://127.0.0.1:3000) and copy the generated server block.
How do I redirect HTTP to HTTPS in nginx?
Use a port-80 server block with return 301 https://$host$request_uri;. The generator includes it.
Why do single-page apps need try_files?
So deep links like /dashboard return index.html and the app's router handles them, instead of a 404.
Is anything uploaded?
No. The file is generated in your browser and nothing is stored or sent.