Answer the question
In order to leave comments, you need to log in
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;
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
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question