Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

365
Vistas
One nginx config for multiple HTTPS (certbot) domains

Now I use one nginx config for many domains.

server {
        listen 80 default_server;
        listen [::]:80 default_server;

        root /home/user/default;
        index index.php;
        server_name _;
        location / {
                try_files $uri $uri/ /index.php?$args;
        }
        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/run/php/php7.2-fpm.sock;
        }
}

I want to transfer sites to the https protocol, will use the CertBot.

Is it also possible to use one config for all domains? How to specify key paths for different domains?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Nginx can't user variable names for SSL cert file paths, so you'll need server blocks for each host specifying the files. You could modularize your config with include

server {
  include conf.d/includes/common.conf;

  host example1.com www.example1.com;  

  ssl_certificate         /etc/nginx/ssl/example1.com/cert.cer;
  ssl_certificate_key     /etc/nginx/ssl/example1.com/privkey.cer;
  ssl_trusted_certificate /etc/nginx/ssl/example1.com/ca.cer;
}

common.conf

listen 443 ssl http2;
listen [::]:443 ssl http2;

root /home/user/$host;
access_log /var/log/nginx/$host-access.log;
error_log  /var/log/nginx/$host-error.log;

ssl_stapling on;
ssl_stapling_verify on;
resolver 8.8.8.8 8.8.4.4;

index index.php;

location / {
  try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
  include snippets/fastcgi-php.conf;
  fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}

Another idea is to use a wildcard cert for a domain, or potentially use a Certbot cert that serves multiple domains, updating it every time a new domain is to be added (never tried and Certbot may have restrictions or disallow multiple domains entirely)

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda