Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

362
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!