Question
Let's encrypt for multiple sites with different domains on same droplet
I’m running Debian 9.2 with nginx and let’s encrypt on a single droplet. I have got SSL to work on fine after following the tutorial for one domain with this default setup in sites-available:
server {
listen 80;
server_name primarydomain.com www.primarydomain.com;
return 301 https://$server_name$request_uri;
}
server {
# SSL configuration
listen 443 ssl;
server_name .primarydomain.com;
root /usr/share/nginx/html/primarydomain.com;
include /etc/nginx/sites-available/include;
include snippets/ssl-primarydomain.com.conf;
include snippets/ssl-params.conf;
}
But then I wanted to have another domain as well as subdomain connected to the same droplet but another /usr/share/nginx/html/ folder so I set it up like this:
#Primary
server {
listen 80;
server_name primarydomain.com www.primarydomain.com;
return 301 https://$server_name$request_uri;
}
server {
# SSL configuration
listen 443 ssl;
server_name .primarydomain.com www.primarydomain.com;
root /usr/share/nginx/html/primarydomain.com;
include /etc/nginx/sites-available/include;
include snippets/ssl-primarydomain.com.conf;
include snippets/ssl-params.conf;
}
#Test.Primary
server {
listen 80;
server_name test.primarydomain.com www.test.primarydomain.com;
return 301 https://$server_name$request_uri;
}
server {
# SSL configuration
listen 443 ssl;
server_name test.primarydomain.com www.test.primarydomain.com;
root /usr/share/nginx/html/test.primarydomain.com;
include /etc/nginx/sites-available/include;
include snippets/ssl-primarydomain.com.conf;
include snippets/ssl-params.conf;
}
#Secondary
server {
listen 80;
server_name secondarydomain.com www.secondarydomain.com;
return 301 https://$server_name$request_uri;
}
server {
# SSL configuration
listen 443 ssl;
server_name .secondarydomain.com www.secondarydomain.com;
root /usr/share/nginx/html/secondarydomain.com;
include /etc/nginx/sites-available/include;
include snippets/ssl-primarydomain.com.conf;
include snippets/ssl-params.conf;
}
Unfortunately this did not work out at all as I thought it would. Is it something with let’s encrypt I need to configure that I’ve missed perhaps?
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×