1. Home
  2. Developer tools
  3. Nginx Config Generator

Nginx Config Generator

Put a Node, Python or Go app behind Nginx with HTTPS, or serve a React or Vue build with working client-side routes.

Free, no sign-up. Runs in your browser: nothing is uploaded.

How to use Nginx Config Generator

  1. Pick proxy, static, SPA or PHP and enter the domains.
  2. Set HTTPS, www redirect and options.
  3. Copy the config, run nginx -t and reload.

Features

  • HTTP → HTTPS and www ⇄ bare-domain redirects
  • proxy_pass with Host, X-Real-IP and X-Forwarded-* headers
  • WebSocket Upgrade headers and long read timeout
  • try_files fallback to index.html for SPAs; PHP-FPM block
  • gzip, long asset caching, HSTS and other security headers

Supported formats

Input

  • Form input

You get

  • CONF

Private by design

Everything you enter is processed by your browser on this device. Nothing is sent to openWorkstand or anyone else, so the Nginx Config Generator is safe for private and work data. After you have used it once while online, it also works without an internet connection. How local processing works

Good to know

  • A Content-Security-Policy is not added because it depends on your site.
  • Load balancing across several upstream servers must be added by hand.

Guide

Nginx server blocks for reverse proxies, single-page apps and PHP

Nginx sits in front of a great many web applications: it terminates HTTPS, serves static files quickly and forwards everything else to an app server. Its configuration language is compact but full of details that matter, from redirect loops to missing proxy headers. This generator writes a complete server block for the four most common setups.

How a server block is organised

Each site is a server { } block that says which addresses and names it answers (listen and server_name) and what to do with requests, usually through location blocks. A typical HTTPS site actually needs several blocks: one on port 80 that redirects to HTTPS, one for the www or bare variant that redirects to the preferred name, and the main one on port 443. The generator writes all of them in the right order.

Four site modes

Reverse proxy mode forwards every request to an app server such as http://127.0.0.1:3000 with proxy_pass, adding the Host, X-Real-IP, X-Forwarded-For and X-Forwarded-Proto headers so the app knows the original host, client and scheme. Static mode serves files from a root folder. Single-page app mode adds try_files $uri $uri/ /index.html, so deep links in React, Vue or Svelte apps load the app instead of a 404. PHP mode passes .php requests to PHP-FPM over its socket.

HTTPS and www redirects

With HTTPS on, the port 80 block answers Let’s Encrypt’s HTTP challenges from /.well-known/acme-challenge/ and redirects everything else with a 301 to HTTPS. The main block listens on 443 with ssl and http2 on, the syntax for Nginx 1.25.1 and later, points at the certificate and key, allows only TLS 1.2 and 1.3 and enables a session cache. Choose whether www. should redirect to the bare domain, the other way round, or serve both.

WebSockets, compression and caching

For apps with live updates, the WebSocket option adds proxy_http_version 1.1 and the Upgrade and Connection headers that let a connection switch protocols, with a long read timeout so idle sockets stay open. Gzip compresses text types above 1 KB. In static and SPA modes, long-lived caching headers for CSS, JavaScript, fonts and images let browsers keep fingerprinted assets for 30 days.

Security headers

The security option adds X-Content-Type-Options: nosniff, X-Frame-Options: SAMEORIGIN and Referrer-Policy: strict-origin-when-cross-origin, plus Strict-Transport-Security with a one-year max-age when HTTPS is on. A Content-Security-Policy is deliberately left out, because a wrong one breaks a site; build it for your pages with the CSP Hash Generator.

A worked example

With the defaults, the first block listens on port 80 for both names and returns return 301 https://example.com$request_uri;. A second block on 443 sends www.example.com to the bare domain. The main block proxies to proxy_pass http://127.0.0.1:3000; with the forwarding headers and proxy_set_header Upgrade $http_upgrade;, enables http2 on;, gzip and the security headers, and accepts uploads up to 20 MB. Switching to single-page app mode replaces the proxy location with try_files $uri $uri/ /index.html;.

Testing and enabling

Save the file under /etc/nginx/sites-available/, link it into sites-enabled, then always run sudo nginx -t before sudo systemctl reload nginx; the test catches syntax errors without taking the running server down. Obtain the certificate first with certbot’s webroot mode, or start without HTTPS and add it after.

Checked against the current version of the Nginx Config Generator on .

Frequently asked questions

Why does my app see 127.0.0.1 as every visitor’s IP?

Behind a reverse proxy, the connection comes from Nginx. The real address is in the X-Real-IP and X-Forwarded-For headers the config sets; tell your framework to trust the proxy (for example trust proxy in Express or ProxyFix in Flask) so it reads them.

What does client_max_body_size do?

It limits the size of request bodies such as uploads. Nginx’s default is 1 MB, and larger requests get 413 Content Too Large before they reach your app, so raise it to the biggest upload you accept.

Why does my React app show 404 on refresh?

The browser asks Nginx for /dashboard, which is not a file. try_files $uri $uri/ /index.html tells Nginx to serve the app’s index.html for unknown paths so the client-side router can take over; the SPA mode adds it.

Is HSTS safe to turn on?

Only when every subdomain works over HTTPS: browsers remember the header for max-age seconds and refuse plain HTTP. Start with a short max-age, then raise it to a year once you are sure.

Keep working with the result

openWorkstand also includes a free workspace with documents, spreadsheets, tasks, projects and a calendar that save to a folder on your computer.