Generador de configuración Nginx

Genera configuraciones de Nginx listas para producción — sitios estáticos, SPAs, proxies inversos y aplicaciones PHP

Tipo de servidor
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;
    }
}

Generador de configuración Nginx

Genera configuraciones de Nginx listas para producción — sitios estáticos, SPAs, proxies inversos y aplicaciones PHP

Características

  • 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`

Cómo usar

  1. Selecciona el tipo de servidor (estático, SPA, proxy inverso o PHP).
  2. Introduce tu nombre de dominio y configura las rutas.
  3. Activa funciones como SSL, gzip, caché y cabeceras de seguridad.
  4. Copia la configuración generada y guárdala en tu servidor.

Consejos y buenas prácticas

  • `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/`.

Preguntas frecuentes

¿Cuál es la diferencia entre el modo estático y SPA?

El modo estático devuelve 404 para rutas desconocidas. El modo SPA redirige todas las rutas a index.html, permitiendo el enrutamiento del lado del cliente (React, Angular, Vue).

¿Debo activar gzip?

Sí, la compresión gzip reduce el tamaño de los archivos en un 60-80 % y mejora significativamente los tiempos de carga de la página.

¿Cómo configuro SSL?

Activa SSL, indica las rutas de tu certificado y clave, y el generador creará automáticamente un bloque de redirección de HTTP a HTTPS.