When installing I got the error “Unable to install the certificate”. I am installing next cloud on Ubuntu server 18.04 with Nginx. I have two Nginx config files. They are:
/etc/nginx/conf.d/default.conf
/etc/nginx/conf.d/nextcloud.conf
When I ran the certbot command, defult.conf did not have a server_name set so that may be why it was unable to install the certificates. It did not set up either of the configuration files to use the certificate. Now they both have the server_name set like so:
/etc/nginx/conf.d/default.conf as server_name blue.[myDomain].com;
/etc/nginx/conf.d/nextcloud.conf as server_name bucket.blue.[myDomain].com;
The command I ran and output it gave is bellow. My question is, is there a way to rerun the certbot command and get it to install the certificate and set up the Nginx configuration files or is there instructions for doing that manually?
Thanks for your help.
I ran this command:
sudo certbot --nginx --agree-tos --redirect --staple-ocsp --email [myEmail]@gmail.com -d bucket.blue.[myDomain].com,blue.[myDomain].com
It produced this output:
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for blue.[myDomain].com
http-01 challenge for bucket.blue.[myDomain].com
Using default addresses 80 and [::]:80 ipv6only=on for authentication.
Waiting for verification…
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/conf.d/nextcloud.conf
Could not automatically find a matching server block. Set the server_name directive to use the Nginx installer.
IMPORTANT NOTES:
Unable to install the certificate
Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/bucket.blue.[myDomain].com/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/bucket.blue.[myDomain].com/privkey.pem
Your cert will expire on 2020-02-27. To obtain a new or tweaked
version of this certificate in the future, simply run certbot again
with the “certonly” option. To non-interactively renew all of
your certificates, run “certbot renew”
Your account credentials have been saved in your Certbot
configuration directory at /etc/letsencrypt. You should make a
secure backup of this folder now. This configuration directory will
also contain certificates and private keys obtained by Certbot so
making regular backups of this folder is ideal.
My web server is (include version):
nginx version: nginx/1.14.0 (Ubuntu)
The operating system my web server runs on is (include version):
Distributor ID: Ubuntu
Description: Ubuntu 18.04.3 LTS
Release: 18.04
Codename: bionic
Everything “looks” OK.
But, for some reason, ‘certbot’ is unable to properly parse through the config and doesn’t locate the server_name entry for bucket.
[passing this to someone more proficient in these matters: @schoen]
Is it possible to use the first option and still have a different root folder for each domain name? I was looking around for examples of how to do this and did not see anything that looks like what I am expecting.
For the second option, is it correct that I would leave the Ngnix configuration as is and run the certbot command twice? Once for each domain?
Sounds good. I will go with two different certificates then. To clarify I just add certonly and rerun the command with one domain name to use the current certificate with one domain name? Like so:
In nginx it is possible (albeit incredible over complicated - but possible).
If you are essentially not going to use the port 80 connections (by redirecting them all to port 443), then you should use a single port 80 block and handle all your challenge requests from a single point.
I ran the certbot command for each of the domains and they seemed to work as expected. I did have trouble getting one of them to redirect 80 to 443. I had to comment out the IPv6 stuff in the default config. It sounds to me like what you are saying is related to that. I have what looks like a port 80 redirect in both vhost files. Something like bellow. So would it be best to only have that in one file?
server {
if ($host = blue.kenzua.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name blue.kenzua.com;
return 404; # managed by Certbot
}