I followed this tutorial.
I have two domains : domain1.com and domain2.com
I want to set up Lets Encrypt such that both my domains have the https certificate. The problem is that I can find no tutorials that explains how to make this work with two domains(my webserver is Nginx).
Right now, i am using the same certificate for both domains. domain1.com works perfectly but domain2.com shows a “NET::ERR_CERT_COMMON_NAME_INVALID” error on chrome.
This is the domain1.com file in the /etc/nginx/sites-available directory:
`server {
listen 80;
server_name domain1.com www.domain1.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name domain1.com www.domain1.com;
ssl_certificate /etc/letsencrypt/live/domain1.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/domain1.com/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA';
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:50m;
ssl_stapling on;
ssl_stapling_verify on;
add_header Strict-Transport-Security max-age=15768000;
root /var/www/domain1.com/html;
index index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
}`
The domain2 file in the /etc/nginx/sites-available directory is completely similar to the above except domain1.com has been replaced with domian2.com and it has been pointed to it’s appropriate root directory.
So what am I doing wrong and how do I fix it ??
TLDR: Running Nginx and hosting two domains. Want to use Lets Encrypt on the two domains but the certificate works on only one domain.
Edit:
I went ahead and did the following:
cd /opt/letsencrypt
./letsencrypt-auto certonly -a webroot --webroot-path=/var/www/domain2.com/html -d domain2.com -d www.domain2.com
Now, I get the following error :
Checking for new version...
Requesting root privileges to run letsencrypt...
/root/.local/share/letsencrypt/bin/letsencrypt certonly -a webroot --webroot-path=/var/www/domain2.com/html -d domain2.com -d www.domain2.com
Failed authorization procedure. www.domain2.com (http-01): urn:acme:error:connection :: The server could not connect to the client to verify the domain :: DNS problem: NXDOMAIN looking up A for www.domain2.com
IMPORTANT NOTES:
- The following errors were reported by the server:
Domain: www.domain2.com
Type: connection
Detail: DNS problem: NXDOMAIN looking up A for www.domain2.com
To fix these errors, please make sure that your domain name was
entered correctly and the DNS A record(s) for that domain
contain(s) the right IP address. Additionally, please check that
your computer has a publicly routable IP address and that no
firewalls are preventing the server from communicating with the
client. If you're using the webroot plugin, you should also verify
that you are serving files from the webroot path you provided.