# Nginx Config Generator - Reverse Proxy, HTTPS & SPA Configs

> Generate Nginx configs for static sites, SPAs, reverse proxies, WebSocket and PHP-FPM with HTTPS, HTTP/2, gzip, caching, security headers and rate limits.

- URL: https://qilingtools.com/en/nginx-config
- Category: Developer Tools (https://qilingtools.com/en/dev)
- Tags: [Developer](https://qilingtools.com/en/tags/dev), [Network & HTTP](https://qilingtools.com/en/tags/network), [DevOps](https://qilingtools.com/en/tags/devops)
- Last updated: 2026-10-26
- Price: Free, no sign-up
- Privacy: Runs locally in the browser; files are never uploaded

Stop piecing together Nginx snippets from blog posts every time you launch a site. Pick a use case, fill in a few fields and get a commented nginx.conf you can drop into conf.d. Use cases include static sites, single-page apps (history-mode routes fall back to index.html, which is never cached), reverse proxies (an upstream block for several backends with round robin, least_conn, ip_hash or random balancing and keepalive), WebSocket proxies (Upgrade headers and long timeouts), PHP-FPM (front controller and fastcgi parameters) and whole-site 301 redirects. Turning on HTTPS adds certificate paths, Mozilla-recommended TLS protocols and ciphers, session caching and HSTS, redirects HTTP to HTTPS while keeping the Let’s Encrypt challenge path, and offers HTTP/2 with either the http2 on; syntax of nginx 1.25.1+ or the older listen flag; you can also force www or the bare domain. Performance and security options cover gzip, 30-day asset caching, security headers, hiding the version, upload size limits, per-IP rate limiting, CORS and basic-auth password protection. A second tab formats minified or messy nginx configs with consistent indentation, keeps comments and checks that braces match.

## How to use

1. Choose a use case: static site, SPA, reverse proxy, WebSocket, PHP or redirect
2. Enter the domain, document root or backends and toggle HTTPS, gzip, caching, headers and more
3. Copy or download the config, run nginx -t on the server and reload

## Features

- Static site, SPA, reverse proxy, WebSocket, PHP-FPM and redirect presets
- Upstream load balancing with keepalive
- HTTPS with Mozilla TLS settings, HSTS, HTTP→HTTPS and HTTP/2
- www / non-www canonical redirects
- gzip, asset caching, security headers, rate limiting, CORS, basic auth
- Commented output, downloadable as .conf
- Nginx config formatter with brace checking

## FAQ

### Where do I put the generated config and how do I apply it?

On Debian and Ubuntu, save it in /etc/nginx/sites-available/ and symlink it into sites-enabled/, or put it straight into /etc/nginx/conf.d/ with a .conf extension (conf.d is included inside the http block, which is why upstream, map and limit_req_zone can sit at the top of the file). Then run nginx -t to check the syntax and nginx -s reload or systemctl reload nginx.

### Where do I get an HTTPS certificate?

Let’s Encrypt is the usual choice. With the challenge path option enabled, start with the HTTP-only config, run certbot certonly --webroot -w /var/www/certbot -d your-domain, and the certificate lands in /etc/letsencrypt/live/your-domain/. Then enable HTTPS and reload; certbot renews it automatically.

### Why does refreshing my single-page app return 404?

History-mode routers such as Vue Router and React Router need every unknown path to be served by index.html, which the SPA preset does with try_files $uri $uri/ /index.html;. The generated config also stops index.html from being cached while hashed assets are cached for a long time, so users get new releases immediately.

### Why did some headers disappear after I added add_header?

Nginx only inherits add_header directives from the server block when a location defines none of its own. That is why the generator keeps security headers, HSTS and CORS at the server level and implements asset caching with expires, which does not break inheritance. If you add add_header inside a location, repeat the headers you need there.

## Related tools

- [JSON Formatter](https://qilingtools.com/en/json): Free online JSON formatter: beautify or minify, validate with the exact line and column of any error, browse a collapsible tree, sort keys and escape strings.
- [Base64 Encode/Decode](https://qilingtools.com/en/base64): Free online Base64 encoder and decoder: UTF-8 safe, optional URL-safe variant, convert text to Base64 and back in real time. Processed locally, never uploaded.
- [URL Encode/Decode](https://qilingtools.com/en/url-encode): Free online URL encoder and decoder with encodeURIComponent and encodeURI modes. Escapes Chinese, spaces and special characters. Real-time and local, no upload.
- [JWT Decoder](https://qilingtools.com/en/jwt): Free online JWT decoder: decode the header and payload of a JSON Web Token, show expiry and issued-at times, all locally without uploading the token.
- [Timestamp Converter](https://qilingtools.com/en/timestamp): Free online Unix timestamp converter: convert timestamps and dates, auto-detect seconds or milliseconds, and show local, UTC, ISO 8601 and relative time.
- [Hash / Checksum](https://qilingtools.com/en/hash): Free online hash calculator: SHA-1, SHA-256, SHA-384 and SHA-512 of text or any file through the browser crypto API. Files never leave your device.
- [UUID Generator](https://qilingtools.com/en/uuid): Free online UUID generator: create RFC 4122 UUID v4 in bulk with a cryptographic RNG. Options for uppercase, no hyphens and braces, with one-click copy.
- [Base Converter](https://qilingtools.com/en/base-convert): Free online number base converter: convert between binary, octal, decimal, hexadecimal and any base 2–36. Uses BigInt for huge integers, computed locally.
