Nginx Config Generator
Build a complete Nginx server block for static sites, PHP, reverse proxies, and Node.js apps — with SSL, gzip, security headers, caching, and rate limiting.
# ───────────────────────────────────────────────────────────── # Nginx configuration — generated by SysAdmin Tools # Server type: Static Site (HTML/CSS/JS) # Place this file in /etc/nginx/sites-available/ and symlink it # into /etc/nginx/sites-enabled/, then run: nginx -t && systemctl reload nginx # ───────────────────────────────────────────────────────────── # ── Main server block ── server { listen 80; listen [::]:80; server_name example.com; root /var/www/html; index index.html index.php; # ── Serve static files ── location / { try_files $uri $uri/ =404; } }
Advertisement
An nginx config generator lets you build a complete, syntactically correct nginx server block visually — without memorising directive names or hunting through documentation. Toggle the features you need on the left, and a ready-to-deploy nginx.conf is written in real time on the right, complete with explanatory comments.
Nginx configuration is powerful but unforgiving: a misplaced semicolon, a wrong location matching order, or a forgotten proxy_set_header can break routing or silently disable WebSockets. This nginx configuration generator online handles the boilerplate for four common scenarios — a static site, a PHP application over FastCGI, a reverse proxy, and a Next.js/Node.js app — and layers optional SSL, gzip, security headers, HSTS, browser caching, rate limiting, custom error pages, and logging on top.
Whether you are standing up a new nginx virtual host, adding nginx SSL config from Let's Encrypt, or wiring up a nginx reverse proxy config generator for a Node.js backend, the tool produces the exact server { } block you need. It runs entirely in your browser — no data is sent anywhere — so you can copy the config or download it as nginx.conf and drop it straight into /etc/nginx/sites-available/.
Every generated block follows current best practice: TLS 1.2 and 1.3 only, an SSL session cache, sensible proxy_pass headers including the Upgrade/Connection pair for WebSockets, and a limit_req_zone placed correctly for nginx rate limiting. Use it as a starting point, then tweak paths to match your server.
How to Use the Nginx Config Generator
- 1
Choose your server type
Pick Static Site, PHP Application, Reverse Proxy, or Next.js/Node.js App. This selects the base template — the correct location blocks, try_files or proxy_pass directives are generated automatically for that scenario.
- 2
Set the basic details
Enter your server name (domain), optionally add the www variant, and set the root directory and index files. These populate the server_name, root, and index directives in the block.
- 3
Enable SSL and security options
Turn on SSL to add certificate paths, TLS 1.2/1.3, and session caching, and optionally force an HTTP→HTTPS redirect. Add HSTS, security headers, gzip compression, and browser caching with a single toggle each.
- 4
Add proxy, PHP, rate limiting or logging
Depending on your server type, set the upstream URL for a reverse proxy or the PHP-FPM socket for FastCGI. Optionally enable rate limiting, custom error pages, and access/error logging with their own paths.
- 5
Copy or download nginx.conf
The live preview updates as you toggle options. Click "Copy Config" to grab the text, or "Download nginx.conf" to save the file. Place it in /etc/nginx/sites-available/, symlink it into sites-enabled/, then run nginx -t and reload.
Understanding the Generated Nginx Config
http {} context holds global directives; inside it, each server block (server { }) is a virtual host matched by listen port and server_name. Within a server block, location blocks (location { }) match request URIs and decide how each is served — from disk with try_files, passed to PHP-FPM with fastcgi_pass, or forwarded to a backend with proxy_pass.
When SSL is enabled the generator emits a block listening on 443 ssl with http2 on, restricts protocols to TLS 1.2 and 1.3, and adds an ssl_session_cache for performance. If you also force HTTPS, a second small server block on port 80 issues a 301 redirect to the secure version. A few directives — most notably limit_req_zone for rate limiting — must live in the http {} context, so the generator places them above the server block with a comment reminding you where they belong.
For reverse proxies, the proxy_pass directive is accompanied by the standard header set (Host, X-Real-IP, X-Forwarded-For, X-Forwarded-Proto) plus proxy_http_version 1.1 and the Upgrade/Connection headers that allow WebSocket connections to pass through — a common thing to forget when proxying Node.js apps.| Field | Description |
|---|---|
| server { } | A virtual host. Matched by the listen port and server_name; contains all directives for one site. |
| listen | The port (and protocol) the block accepts connections on — 80 for HTTP, 443 ssl for HTTPS. |
| server_name | The domain(s) this block answers for, e.g. example.com www.example.com. |
| location | Matches request URIs and defines how they are served — static files, FastCGI, or proxied upstream. |
| proxy_pass | Forwards matching requests to an upstream address such as http://127.0.0.1:3000 for a Node.js app. |
| fastcgi_pass | Passes PHP requests to a PHP-FPM socket or TCP address for processing. |
| ssl_certificate | Path to the fullchain certificate (and ssl_certificate_key to the private key), typically from Let's Encrypt. |
| limit_req_zone | Defines a shared memory zone for rate limiting. Must be declared in the http {} context, not inside a server block. |
Advertisement
Common Nginx Config Use Cases
Reverse proxy for a Node.js app
Put Nginx in front of a Node.js or Next.js process listening on localhost:3000. The generated proxy_pass block forwards traffic, sets the correct headers, and enables WebSocket upgrades — the standard production setup for Node apps.
Serve a PHP site with FastCGI
Generate a PHP-FPM configuration with the correct fastcgi_pass socket, a front-controller try_files rule, and a location block that denies access to hidden files like .env — ideal for Laravel, WordPress, or a custom PHP app.
Add Let's Encrypt SSL to a site
Enable SSL to produce a 443 server block with TLS 1.2/1.3, session caching, and optional HSTS, plus a port-80 block that redirects HTTP to HTTPS. Point the certificate paths at your Let's Encrypt fullchain and privkey files.
Harden and speed up a static site
For a static HTML/CSS/JS site, add gzip compression, long-lived browser caching for images, fonts, and assets, and a full set of security headers — turning a bare server block into a production-ready configuration.