Nginx Config Generator

Get a correct, commented Nginx configuration for your site in one go: HTTPS with redirects, security headers, compression, asset caching, WebSockets and rate limits.

Funziona nel tuo browser. I tuoi file non lasciano mai il dispositivo. Scopri come verificarlo

…

Come si usa

  1. 1
    Choose the site type

    Static, single-page app, proxy or PHP.

  2. 2
    Enter domain and paths

    Domains, web root, upstream or PHP socket.

  3. 3
    Set security

    HTTPS, HSTS, headers and www handling.

  4. 4
    Set performance

    Gzip, caching, HTTP/2, upload size and rate limit.

  5. 5
    Save

    Download the .conf file.

  6. 6
    Test and reload

    Run nginx -t and reload Nginx.

Informazioni su questo strumento

Nginx serves a large share of the web, but its configuration is unforgiving: a missing semicolon stops it from starting, a wrong try_files breaks a single-page app's deep links, and many copied snippets still use outdated TLS settings or forget security headers. This generator writes a full server configuration for the four most common setups: static files, a single-page app that sends unknown routes to index.html, a reverse proxy in front of Node, Python or any upstream, and PHP through PHP-FPM for WordPress or Laravel. You choose HTTPS with the Let's Encrypt certificate paths and an HTTP to HTTPS redirect, HSTS, a www or bare-domain redirect, gzip compression, long caching for fingerprinted assets, HTTP/2, an upload size limit and a per-IP rate limit. The output comes with the commands to test and reload Nginx and to get the certificate.

Site types

- Static: files served from the web root with try_files $uri $uri/ =404. - Single-page app: unknown paths fall back to /index.html, and index.html itself is never cached so new releases appear at once. - Reverse proxy: forwards Host, client IP and scheme headers, with optional WebSocket upgrade handling. - PHP-FPM: front-controller routing to index.php and blocked access to hidden files such as .env.

HTTPS

TLS 1.2 and 1.3 only, session caching, and certificate paths matching certbot's layout. The port 80 server answers ACME challenges for renewals and redirects everything else to HTTPS. HSTS tells browsers to use HTTPS for a year; add preload only when every subdomain supports HTTPS.

Security headers

X-Content-Type-Options, X-Frame-Options, Referrer-Policy and Permissions-Policy are added with always so they appear on error pages too, and server_tokens off hides the Nginx version. Add a Content-Security-Policy suited to your site separately.

Performance

Gzip compresses text formats; images and video are already compressed. Fingerprinted assets get a one-year immutable cache. HTTP/2 multiplexes requests over one connection.

Applying it

Save the file under sites-available, link it into sites-enabled, run nginx -t to check the syntax, then reload. For HTTPS, get the certificate first so Nginx can start with the TLS lines in place.

Limits

Configurations for load balancing several upstreams, caching proxies or complex rewrites go beyond this generator. The http2 on directive needs Nginx 1.25.1 or newer. Test in staging before production; this is general guidance, not a security audit.

Esempio svolto

A React app on example.com with HTTPS, www redirected to the bare domain, gzip, a one-year cache for assets and a 20 MB upload limit gives three server blocks: the port 80 redirect, the www redirect and the main HTTPS server with SPA routing.

In breve

Domande frequenti

Which setups are covered?

Static sites, single-page apps, reverse proxies with WebSockets and PHP-FPM.

Does it include HTTPS?

Yes, with Let's Encrypt paths, a redirect from HTTP and optional HSTS.

How do I check the file before using it?

Run sudo nginx -t, which reports any syntax error with its line.

Why does my SPA show 404 on refresh?

It needs the fallback to index.html that the single-page app option adds.

Can I limit abusive traffic?

Yes. Set a rate limit per IP in requests per second.

Is anything uploaded?

No. The configuration is generated in your browser.

Completamente gratisNessun costo, nessuna registrazione
I file restano privatiTutto funziona nel tuo browser
Facile nella tua linguaDisponibile in molte lingue