Account

What new tool do you want?

Developer Tools

Nginx Config Generator

Generate an nginx server block for a static site, SPA or reverse proxy — with HTTPS (Let's Encrypt paths), HTTP→HTTPS and www redirects, gzip and caching.

How to use

  1. 1Enter your domain and choose the site type.
  2. 2Save the output as /etc/nginx/sites-available/<domain>, symlink it into sites-enabled, then run nginx -t and reload.

Frequently asked questions

How do I get the SSL certificate?

Run certbot --nginx -d example.com -d www.example.com (or certbot certonly). The config uses the standard /etc/letsencrypt/live paths.

What does the SPA option do?

It adds try_files … /index.html so client-side routes (like /about) load your single-page app instead of a 404.

Why proxy_set_header lines?

They pass the real client IP, host and protocol to your app, which it needs for logging, redirects and secure cookies.

Worked example: Nginx Config Generator

With the defaults (example.com, reverse proxy to 127.0.0.1:3000, HTTPS on, www redirect on), the generator produces three separate server blocks: one listening on port 80 that 301-redirects everything to https://example.com, one for www.example.com that redirects to the bare domain, and the main HTTPS server block with the SSL certificate paths and the actual proxy_pass directive. Turn HTTPS off and www off, and it collapses to a single plain port-80 server block with no redirects at all — the generator adds exactly as many server blocks as the redirect logic requires, not a fixed number.

Why the proxy_set_header lines matter more than they look

Without Host, X-Real-IP, X-Forwarded-For and X-Forwarded-Proto being forwarded, your backend app sees every request as coming from 127.0.0.1 (nginx itself) over plain HTTP, no matter what the actual client sent — which breaks IP-based rate limiting, request logging, and any code that checks `req.secure` to decide whether to set a cookie's Secure flag. The Upgrade/Connection pair specifically exists for WebSocket connections; without them, a reverse-proxied WebSocket app (chat, live updates) fails to upgrade the connection and silently falls back to polling or breaks outright.

What you still have to do by hand

Generating the config file is the easy half — getting the actual certificate still requires running certbot --nginx -d example.com -d www.example.com on the server once the config is in place and nginx is pointed at port 80 (Let's Encrypt's HTTP-01 challenge needs that to succeed first). The generated paths (/etc/letsencrypt/live/<domain>/fullchain.pem) assume certbot's default layout, so if you provision certificates differently (a load balancer terminating TLS, a wildcard cert from a different CA), you'll need to adjust the ssl_certificate lines accordingly.

Why static and SPA sites get a caching block that proxy mode doesn't

Choosing static site or single-page app adds a second location block matching asset extensions (css, js, woff2, svg, png, jpg, and friends) that sets expires 30d and Cache-Control: public, immutable — a sensible default for assets served straight off disk, since nginx can see the actual files and knows a hashed filename like app.3f8a1c.js never changes once built. Reverse proxy mode skips this entirely, because nginx in that setup is just forwarding bytes from your upstream app without ever seeing the files — any caching policy has to come from the headers your app itself sends, not from nginx guessing. If you reverse-proxy a Node or Python app that also happens to serve a built frontend bundle, you may want to serve those static assets directly with the static-site template instead of punting everything through the app process.

Related tools

More: Developer Tools