A
A
Azigar2019-09-09 21:52:08
Nginx
Azigar, 2019-09-09 21:52:08

Let's Encrypt and automatic subdomains?

I use the following construction for automatic subdomains:

server_name     mysite.com *.mysite.com;
     set $path       /var/www/mysite.com;
     set $subdomain  "www";

     if ($host ~* ^([a-z0-9-\.]+)\.mysite.com$) {
          set $subdomain $1;
     }

     set  $root_path  $path/$subdomain;
     root $root_path;

Subdomains work perfectly.
Installed certbot. He added the following lines to my domain config:
listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/mysite.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/mysite.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
    if ($host = mysite.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

     listen  80;

     server_name        mysite.com *.mysite.com;
    return 404; # managed by Certbot
}

But now subdomains stopped working? How to make them work again or is it impossible and for each subdomain you need to compose your own config?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
ky0, 2019-09-09
@ky0

LE has been able to wildcard for some time now. Well or yes - separate configs. You can also add a variable equal to the host name to the path to the SSL files.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question