Free tool

Nginx Config Generator

Production-ready server blocks: static site, SPA fallback or reverse proxy with WebSocket, SSL and security headers.

HTTPS with Let's Encrypt
Gzip
Asset cache (30 days)
Security headers
server {
    listen 80;
    http2 off;
    server_name midominio.com;
    client_max_body_size 10M;
    root /var/www/midominio;
    index index.html index.htm;
    add_header X-Frame-Options "DENY" always;
    add_header X-Content-Type-Options "nosniff" always;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~* \.(css|js|jpg|jpeg|png|gif|svg|webp|avif|woff2?)$ {
        expires 30d;
        add_header Cache-Control "public, immutable";
    }
}

# En el bloque http {} de /etc/nginx/nginx.conf:
# gzip on;
# gzip_types text/plain text/css application/json application/javascript image/svg+xml;
# gzip_min_length 1024;
# gzip_comp_level 6;

Built by

Miguel Ángel Colorado Marin (MACM)

Full-Stack Developer · Guadalajara, España

I develop web apps, digital tools and full projects — from design to deployment.

Contact me

A well-configured Nginx server block solves basic performance (gzip, asset cache), security (anti-clickjacking headers, HSTS) and the typical cases that break modern applications all at once: SPA routing that needs everything redirected to index.html, or a Node/Python backend that must receive the original client headers correctly. This generator composes the configuration based on your site type and options, including the automatic HTTPS redirect with Let's Encrypt certificate paths when you enable SSL, WebSocket support for proxies and an adjustable client_max_body_size for large uploads.

Features

  • 3 modes: static, SPA and reverse proxy
  • HTTP→HTTPS redirect + SSL block ready for Let's Encrypt
  • Immutable caching for static assets
  • XFO, XCTO and HSTS headers
  • Gzip with recommended types

How to generate an Nginx configuration?

  1. 1

    Pick the site type

    Static, SPA with index.html fallback, or reverse proxy.

  2. 2

    Fill in domain and paths

    server_name, root or proxy target, and max upload size.

  3. 3

    Toggle what you need

    SSL, gzip, asset cache and security headers.

  4. 4

    Deploy the file

    Save it under /etc/nginx/sites-available/, symlink it and reload with nginx -s reload.

Frequently asked questions

Where do I save this file?

On Debian/Ubuntu: /etc/nginx/sites-available/yourdomain plus a symlink from /etc/nginx/sites-enabled/. On RHEL/Fedora put it inside /etc/nginx/conf.d/. Always validate with nginx -t before reloading.

Why does my SPA return 404 on refresh?

Because the browser requests /some/route and no physical file exists there. The SPA mode uses try_files $uri $uri/ /index.html to always serve the app and let the frontend router handle the URL.

Does the tool connect to my server?

No, it only generates text locally. It never accesses your server nor validates against it; run nginx -t on your machine to validate.

Related tools

Embed Nginx Config Generator on your site

Add Nginx Config Generator to any web page with a simple iframe. Free, with attribution to miguelacm.es.

<iframe
  src="https://miguelacm.es/embed/nginx-config-generator"
  width="100%"
  height="700"
  frameborder="0"
  title="Nginx Config Generator — miguelacm.es"
></iframe>
View embed in new tab →