Clone
1
SSL
groales edited this page 2025-11-29 17:16:45 +01:00

Certificados SSL/TLS

Let's Encrypt (Recomendado)

NPM integra Let's Encrypt para certificados SSL gratuitos y automáticos.

Requisitos

  • Dominio apuntando al servidor (registro A/AAAA en DNS)
  • Puertos 80 y 443 accesibles desde Internet
  • Firewall configurado para permitir tráfico entrante

Solicitar Certificado (HTTP Challenge)

  1. Crear/Editar Proxy Host
  2. Pestaña SSL:
    • Request a new SSL Certificate with Let's Encrypt
    • Email: tu@email.com (para notificaciones de expiración)
    • Force SSL (redirigir HTTP → HTTPS automáticamente)
    • HTTP/2 Support
    • HSTS Enabled (opcional, recomendado para seguridad)
    • I Agree to the Let's Encrypt Terms of Service
  3. Save

El certificado se generará en 10-30 segundos.

Renovación Automática

NPM verifica certificados diariamente y renueva automáticamente los que están por expirar (< 30 días).

No requiere configuración adicional.

Certificados Wildcard (DNS Challenge)

Para certificados wildcard (*.tudominio.com) se requiere DNS challenge.

Proveedores DNS Soportados

NPM soporta +100 proveedores via Certbot plugins. Los más comunes:

  • Cloudflare
  • Amazon Route53
  • Google Cloud DNS
  • DigitalOcean
  • OVH
  • Namecheap
  • GoDaddy
  • etc.

Configurar DNS Challenge

Ejemplo: Cloudflare

  1. Obtener API Token de Cloudflare:

    • Login en Cloudflare Dashboard
    • Profile → API Tokens → Create Token
    • Template: "Edit zone DNS"
    • Zone Resources: Include → Specific zone → tudominio.com
    • Continue → Create Token
    • Copiar token
  2. En NPM: SSL Certificates → Add SSL Certificate:

    • Domain Names: *.tudominio.com, tudominio.com (ambos)
    • Use a DNS Challenge
    • DNS Provider: Cloudflare
    • Credentials File Content:
      dns_cloudflare_api_token = TU_TOKEN_AQUI
      
    • Email: tu@email.com
    • I Agree to the Let's Encrypt Terms of Service
    • Save
  3. Usar el certificado:

    • Al crear Proxy Hosts, en pestaña SSL:
    • Seleccionar certificado wildcard existente
    • No marcar "Request a new SSL Certificate"

Otros Proveedores DNS

Amazon Route53:

dns_route53_access_key_id = YOUR_ACCESS_KEY
dns_route53_secret_access_key = YOUR_SECRET_KEY

Google Cloud DNS:

dns_google_credentials = /path/to/credentials.json

DigitalOcean:

dns_digitalocean_token = YOUR_TOKEN

OVH:

dns_ovh_endpoint = ovh-eu
dns_ovh_application_key = YOUR_APP_KEY
dns_ovh_application_secret = YOUR_APP_SECRET
dns_ovh_consumer_key = YOUR_CONSUMER_KEY

Consulta Certbot DNS plugins para más proveedores.

Certificados Propios

Subir Certificado y Clave Privada

  1. SSL Certificates → Add SSL Certificate

  2. Custom:

    • Name: Nombre descriptivo (ej: "MiEmpresa Wildcard")
    • Certificate Key: Pegar contenido del archivo .key
    • Certificate: Pegar contenido del archivo .crt o .pem
    • Intermediate Certificate: (opcional) Cadena de certificados intermedios
    • Save
  3. Usar en Proxy Host:

    • Pestaña SSL → Seleccionar certificado custom
    • Force SSL
    • HTTP/2 Support

Formato de Certificados

Certificado (Certificate)

-----BEGIN CERTIFICATE-----
MIIFXzCCBEegAwIBAgISBGP...
... (contenido base64) ...
-----END CERTIFICATE-----

Clave Privada (Certificate Key)

-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQ...
... (contenido base64) ...
-----END PRIVATE KEY-----

Certificado Intermedio (Intermediate Certificate)

Si tu CA proporciona cadena de certificados:

-----BEGIN CERTIFICATE-----
(Certificado Intermedio 1)
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
(Certificado Intermedio 2)
-----END CERTIFICATE-----

Convertir Formatos

PFX/P12 a PEM:

# Extraer clave privada
openssl pkcs12 -in certificate.pfx -nocerts -out key.pem -nodes

# Extraer certificado
openssl pkcs12 -in certificate.pfx -clcerts -nokeys -out cert.pem

DER a PEM:

openssl x509 -inform der -in certificate.cer -out certificate.pem

HTTP/2 y HTTP/3

HTTP/2

Habilitado por defecto al activar SSL en Proxy Host.

HTTP/2 Support en pestaña SSL.

HTTP/3 (QUIC)

NPM soporta HTTP/3 pero requiere configuración adicional:

docker exec -it nginx-proxy-manager /bin/bash

cat > /data/nginx/custom/server_proxy.conf << 'EOF'
# HTTP/3
listen 443 quic reuseport;
add_header Alt-Svc 'h3=":443"; ma=86400';
EOF

exit
docker exec nginx-proxy-manager nginx -s reload

Abrir puerto UDP 443:

ports:
  - "80:80"
  - "81:81"
  - "443:443"
  - "443:443/udp"  # HTTP/3

HSTS (HTTP Strict Transport Security)

HSTS fuerza a los navegadores a usar HTTPS siempre.

Habilitar en Proxy Host

Pestaña SSL:

  • HSTS Enabled
  • HSTS Subdomains (opcional, incluye subdominios)

Esto añade el header:

Strict-Transport-Security: max-age=31536000; includeSubDomains

HSTS Preload

Para máxima seguridad, añadir tu dominio al HSTS Preload List.

Configuración custom:

# En Proxy Host → Advanced → Custom Nginx Configuration
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;

Luego enviar dominio a hstspreload.org.

Configuración Avanzada de SSL

Cipher Suites Personalizados

Para mayor compatibilidad o seguridad:

# En /data/nginx/custom/server_proxy.conf
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384';
ssl_prefer_server_ciphers off;

OCSP Stapling

Mejora rendimiento SSL:

ssl_stapling on;
ssl_stapling_verify on;
ssl_trusted_certificate /etc/letsencrypt/live/tudominio.com/chain.pem;
resolver 1.1.1.1 8.8.8.8 valid=300s;
resolver_timeout 5s;

Session Cache

Reducir overhead de handshakes SSL:

ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;

Troubleshooting

Error: DNS Challenge Failed

Síntomas: Certificado wildcard no se genera.

Causas:

  • API token/credenciales incorrectas
  • Permisos insuficientes del token
  • Propagación DNS lenta

Soluciones:

# Ver logs detallados
docker logs nginx-proxy-manager | grep certbot

# Verificar permisos de token (Cloudflare)
# Token debe tener: Zone:DNS:Edit

# Esperar propagación DNS (puede tardar minutos)

Error: Rate Limit Exceeded

Let's Encrypt tiene límites:

  • 5 certificados por dominio/semana
  • 50 certificados por cuenta/semana

Solución:

  • Esperar 7 días para reset
  • Usar certificados wildcard (cubre múltiples subdominios con 1 cert)
  • Durante desarrollo, usar staging environment

Certificado No Se Renueva

Verificar:

# Ver logs de renovación
docker logs nginx-proxy-manager | grep renew

# Listar certificados
docker exec nginx-proxy-manager certbot certificates

Forzar renovación manual:

docker exec nginx-proxy-manager certbot renew --force-renewal
docker exec nginx-proxy-manager nginx -s reload

Error: Port 80 Not Available

Let's Encrypt HTTP challenge requiere puerto 80.

Si puerto 80 no está disponible:

  1. Usa DNS challenge (wildcard)
  2. O libera puerto 80 temporalmente

Verificar Certificado SSL

Desde línea de comandos:

# Ver detalles del certificado
echo | openssl s_client -servername tudominio.com -connect tudominio.com:443 2>/dev/null | openssl x509 -noout -dates

# Test desde exterior
curl -vI https://tudominio.com 2>&1 | grep -i ssl

# SSL Labs test (rating A-F)
# https://www.ssllabs.com/ssltest/analyze.html?d=tudominio.com

Volver a: Página Principal | Configuración Avanzada