Start a project

Tool 93 of 100 · Server

nginx Config Generator

Answer a few questions and get a production-ready nginx server block with HTTPS redirects, HTTP/2, security headers, compression and asset caching, explained line by line.

nginx Config Generator at a glanceIllustration: 1, Site settings; 2, processed in your browser; 3, nginx config.nginx Config Generator1Site settings$ curl -X→ fetch()3nginx config2In yourbrowser
1 Site settings 2 processed on your device 3 nginx config

nginx Config Generator

Site

nginx.conf server block

nginx configuration

    01

    What it does

    Builds a complete nginx server block for static sites, SPAs, reverse proxies or PHP-FPM, with HTTPS, headers, caching and limits.

    • Static site, single-page app, reverse proxy or PHP-FPM
    • HTTP to HTTPS and www redirects
    • HTTP/2, HSTS and security headers
    • gzip and long caching for hashed assets

    02

    Private by design

    Everything happens in your browser. Nothing you type, paste or upload is sent anywhere, and it keeps working offline once the page has loaded.

    03

    What you get

    nginx.conf server blocks, with a Copy and a Download button on every result.

    • nginx
    • Server
    • HTTPS
    • DevOps

    Why it matters

    nginx is powerful and unforgiving: a missing try_files breaks a single-page app's routes, a proxy without the right headers loses the client's IP, and add_header inside a location silently drops the headers set above it.

    This generator writes a complete, commented server block for the common setups and explains each choice, including the traps. Test it with nginx -t on your server before reloading.

    How it works

    1. InputDomain, site type and options
    2. In your browserBuilt from hardened defaults
    3. OutputA server block and setup steps

    Where it fits in a designer's workflow

    1. Plan
    2. Design
    3. Build
    4. Test
    5. Launch
    Launching on a VPS.

    By the numbers

    Lines generated for each site type (HTTPS, HSTS, gzip on)Static site: 78 lines; Single-page app: 81 lines; Reverse proxy: 80 lines; PHP-FPM: 86 linesStatic site78 linesSingle-page app81 linesReverse proxy80 linesPHP-FPM86 lines
    Counted from this tool's own output for example.co.uk with HTTPS, IPv6, security headers, gzip and caching switched on. Most of each file is the same hardening; what changes is the location block. Source: nginx documentation.
    Show the numbers as a table
    Site typeLines
    Static site78
    Single-page app81
    Reverse proxy80
    PHP-FPM86

    How to use it

    1. Enter your domain and choose what the server does.
    2. Pick HTTPS, headers, compression and caching options.
    3. Read the notes about the choices.
    4. Download the config and test it with nginx -t.

    FAQ

    Where does the file go?

    Usually /etc/nginx/sites-available/ with a link in sites-enabled, or /etc/nginx/conf.d/yourdomain.conf. Then run sudo nginx -t and sudo systemctl reload nginx.

    Does it get the certificate?

    No. The paths match Certbot's defaults; run certbot --nginx -d yourdomain first.

    Why are headers repeated in some locations?

    nginx only inherits add_header lines if a location sets none of its own, so any location with its own headers needs them all.

    Is HSTS safe to turn on?

    Once every subdomain works over HTTPS. Browsers will refuse plain HTTP for the max-age you set.

    Work with me

    Want a site that gets these right?

    I build fast, accessible websites and web apps that pass these checks from day one. Tell me about your project and I'll reply personally with honest next steps.

    All developer tools · Back to leej.uk