What it does
Builds a server block for Ubuntu's /etc/nginx/sites-available/. Choose static files or a reverse proxy, then add HTTPS, upload size, compression, logging, security headers and a request rate limit. Lines that may only live in the http block — log_format, limit_req_zone, the WebSocket map — come out as a separate /etc/nginx/conf.d/ file, named after the site so several sites on one server do not clash.
Examples
| You pick | Lines you get |
|---|---|
| Reverse proxy | proxy_pass http://127.0.0.1:3000; plus Host, X-Forwarded-For, X-Forwarded-Proto headers |
| WebSocket | proxy_set_header Upgrade $http_upgrade; and Connection through a map |
| HTTP → HTTPS | a port-80 block with return 301 https://$host$request_uri; |
| 20 MB uploads | client_max_body_size 20m; (default 1m, larger requests get 413) |
| Rate limit | limit_req_zone … rate=10r/s; (conf.d) + limit_req zone=… burst=20 nodelay; |
| Log with timing | rt=$request_time uct=… urt=$upstream_response_time |
Common mistakes
log_formatorlimit_req_zoneinside a server block —nginx -trejects them with "directive is not allowed here". They belong in thehttpblock (conf.d/*.confon Ubuntu).- Enabling HTTPS before the certificate exists —
nginx -tfails when thessl_certificatefile is missing. Get the certificate first, or start with HTTPS off. server_name _next to Ubuntu's default site — the default site (sites-enabled/default) also uses_, so nginx warns "conflicting server name". If your block is meant to catch everything, remove the default site's link.burst=0— nginx rejects 0. To allow no burst, leaveburstout (this tool does that for 0).
How it was checked
Before publishing, 52 option combinations were checked with nginx -t from Ubuntu 24.04's nginx 1.24 package, unpacked without installing (no daemon started). The http block repeats Ubuntu's nginx.conf with paths changed, certificates were throwaway self-signed ones, some combinations ran next to Ubuntu's default site, and one run put three sites on the same server. A pass required zero warnings ([warn]) — 66 checks in total. This is a syntax check: whether your app answers still has to be tested.
FAQ
What is the difference between sites-available and sites-enabled?
Ubuntu's nginx.conf reads only sites-enabled/. Keep the file in sites-available/ and enable it with an ln -s link in sites-enabled/. Removing the link turns the site off and keeps the file.
Restart or reload after a change?
Check with sudo nginx -t, then sudo systemctl reload nginx. A reload swaps workers to the new config without dropping open connections, and if the new config is broken nginx keeps running the old one.
Is what I type sent to a server?
No. The config is built in your browser. Domains, paths and upstream addresses are not sent to a server and are not passed to the analytics or ads this site uses. See the privacy notice.