Nginx Config Generator

Generate production-ready Nginx configurations — static sites, SPAs, reverse proxies, and PHP apps

Server Type
nginx.conf
server {
    listen 80;
    server_name example.com;

    client_max_body_size 10m;

    root /var/www/html;
    index index.html;

    gzip on;
    gzip_vary on;
    gzip_min_length 1024;
    gzip_types text/plain text/css application/json application/javascript text/xml application/xml text/javascript image/svg+xml;

    add_header X-Frame-Options "SAMEORIGIN" always;
    add_header X-Content-Type-Options "nosniff" always;
    add_header X-XSS-Protection "1; mode=block" always;
    add_header Referrer-Policy "strict-origin-when-cross-origin" always;

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

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

    location ~ /\. {
        deny all;
    }
}

Nginx Config Generator

Generate production-ready Nginx configurations — static sites, SPAs, reverse proxies, and PHP apps

Features

  • Static site, SPA, reverse proxy, or PHP server presets
  • TLS / HTTPS redirect block with Let's Encrypt-friendly defaults
  • Gzip compression + browser-cache headers for static assets
  • Security headers (X-Frame-Options, X-Content-Type-Options, Referrer-Policy, Permissions-Policy)
  • Optional rate limiting with `limit_req_zone` hint + per-location `limit_req`

How to use

  1. Selecteer uw servertype (statisch, SPA, reverse proxy of PHP).
  2. Voer uw domeinnaam in en configureer de paden.
  3. Schakel functies in zoals SSL, gzip, caching en beveiligingsheaders.
  4. Kopieer de gegenereerde configuratie en sla deze op op uw server.

Tips & Best Practices

  • `limit_req_zone` MUST live in the `http {}` block, not inside `server {}`. The generator emits a comment showing where to put it.
  • Test the config with `nginx -t` before reloading. The output is template-grade; expect to tune for your specific environment.
  • For Let's Encrypt, run certbot once to fetch certs; the paths in the generated config (`/etc/letsencrypt/live/<domain>/`) are the standard locations.
  • Reverse-proxy mode forwards to `proxy_pass http://localhost:3000` — adjust the upstream URL for your backend.
  • For multi-domain configs, generate per-domain server blocks and concatenate them in `/etc/nginx/sites-available/`.

FAQ

Wat is het verschil tussen statische en SPA-modus?

De statische modus retourneert 404 voor onbekende paden. De SPA-modus leidt alle paden om naar index.html, waardoor routing aan clientzijde (React, Angular, Vue) mogelijk wordt.

Moet ik gzip inschakelen?

Ja, gzip-compressie verkleint bestanden met 60-80% en verbetert de laadtijden van pagina's aanzienlijk.

Hoe stel ik SSL in?

Schakel SSL in, geef de paden van uw certificaat en sleutel op, en de generator maakt automatisch een HTTP-naar-HTTPS-omleidingsblok aan.