Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

367
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda