Nginx Config Generator
Build nginx server blocks for reverse proxy, SSL, static sites, SPAs, PHP, and load balancers.
Client-side only — nothing leaves your browser
Space-separate for multiple domains. Use _ to catch all hostnames.
Where to forward requests. Common: http://localhost:3000 for Node/Next.js.
Max upload size. Leave blank to use nginx default (1M).
server {
listen 80;
listen [::]:80;
server_name example.com www.example.com;
# Redirect all HTTP traffic to HTTPS
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name example.com www.example.com;
# SSL certificate (e.g. issued by Let's Encrypt / certbot)
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
# Modern TLS configuration
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
client_max_body_size 10M;
# gzip compression
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_comp_level 6;
gzip_types text/plain text/css text/xml application/json application/javascript application/xml+rss application/atom+xml image/svg+xml;
# Forward all traffic to the upstream application
location / {
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
# WebSocket support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
Save to /etc/nginx/sites-available/example.conf, symlink into sites-enabled/, then run sudo nginx -t && sudo systemctl reload nginx.
What Is an Nginx Config File?
An nginx config file tells nginx how to listen for incoming requests and what to do with them — serve a static directory, proxy to a backend application, terminate TLS, load balance across upstream servers, or any combination. Nginx config uses its own declarative syntax built from directives (single-line settings like listen 443 ssl;) and contexts (curly-brace blocks like server { ... }, location / { ... }, upstream backend { ... }). On Ubuntu and Debian the main file lives at /etc/nginx/nginx.conf and per-site server blocks go in /etc/nginx/sites-available/, symlinked into sites-enabled/.
Common Nginx Directives Reference
| Directive | Purpose | Example |
|---|---|---|
| listen | Port (and optional ssl/http2 flags) the server block binds to | listen 443 ssl http2; |
| server_name | Hostname(s) this server block matches | example.com www.example.com |
| root | Filesystem directory for serving files | /var/www/example.com |
| index | Default file(s) to serve for a directory request | index.html index.htm |
| location | Match a URL prefix or pattern to apply rules | location /api/ { ... } |
| proxy_pass | Forward the request to an upstream URL | proxy_pass http://127.0.0.1:3000; |
| upstream | Define a named pool of backend servers | upstream backend { server 10.0.0.1; } |
| return | Reply immediately with a status code (great for redirects) | return 301 https://$host$request_uri; |
| try_files | Try files in order, fall back to the last argument | try_files $uri $uri/ /index.html; |
| client_max_body_size | Max request body size (upload limit) | client_max_body_size 100M; |
| ssl_certificate | Path to the TLS certificate chain (PEM) | /etc/letsencrypt/live/.../fullchain.pem |
| gzip | Toggle response compression | gzip on; |
After You Paste the Config
The standard workflow on Ubuntu/Debian once you have your generated server block:
- Save it to
/etc/nginx/sites-available/yoursite.conf. - Symlink into the enabled directory:
sudo ln -s /etc/nginx/sites-available/yoursite.conf /etc/nginx/sites-enabled/. - Test the syntax:
sudo nginx -t. If this prints "test is successful", you're good. Otherwise it tells you the line number to fix. - Reload nginx without dropping connections:
sudo systemctl reload nginx(orsudo nginx -s reload). - For SSL, issue a certificate first:
sudo certbot --nginx -d example.com -d www.example.com.
A dedicated nginx config tester / validator and nginx config checker are on the roadmap — for now, nginx -t is the canonical way to validate a generated config before reloading.
Frequently Asked Questions
Where is the nginx config file located?
What is the difference between sites-available, sites-enabled, and conf.d?
How do I configure nginx as a reverse proxy?
How do I test an nginx config before reloading?
How do I redirect HTTP to HTTPS in nginx?
Related Tools
Nginx to Caddy Converter
Convert nginx server blocks to Caddyfile syntax. Maps reverse_proxy, TLS, redirects, and headers.
Traefik Label Generator
Generate Traefik v2/v3 Docker labels visually. Build host rules, TLS, redirects, basic auth, and middleware.
Docker Compose Generator
Build docker-compose.yml visually. Add services, volumes, networks, env vars — with live YAML and lint warnings.
Dockerfile Generator
Build Dockerfiles from form inputs. Multi-stage builds, healthchecks, and best-practice hints inline.
PM2 Ecosystem Generator
Visual builder for ecosystem.config.js. Configure cluster mode, env vars, watch, and max_memory_restart.
Need to manage SSH connections?
SSH Workbench lets you connect, browse files, and manage servers visually.
Try SSH Workbench Free