Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using certbot-auto for nginx

I have an nginx running. Now I want my nginx to use SSL:

certbot-auto --nginx -d my.domain.com -n --agree-tos --email [email protected]

OUTPUT:

Performing the following challenges:
tls-sni-01 challenge for my.domain.com
Cleaning up challenges
Cannot find a VirtualHost matching domain my.domain.com.

my.domain.com is pointing to the IP of my server. It's its dns name. What am I doing wrong? I did this already for apache and it was working fine. My nginx is running (and I'm not able to restart it manually after the certbot-auto but this wasn't necessary when I used certbot-auto --apache

like image 973
DenCowboy Avatar asked Oct 20 '16 08:10

DenCowboy


People also ask

Does Letsencrypt auto-renew?

Did you know that you can quickly configure your Let's Encrypt certificates to automatically renew themselves by executing a simple letsencrypt auto-renew script? Configuring auto-renew for you Let's Encrypt SSL certificates means your website will always have a valid SSL certificate.

How do I renew my SSL certificate automatically?

Turn on Auto-Renew In the Order # column, click the Quick View link of the SSL certificate. In the Quick View pane on the right, click + Show More Certificate Info... to expand the Order Details section. Under Auto-Renew, check the box or select the total number of times you want to renew the certificate.


2 Answers

In my case, I had to add the "server_name" line because it wasn't in my nginx config so it was giving me the error message "Cannot find a VirtualHost matching domain my.domain.com" when I ran:

certbot --nginx

Make sure this is in your config:

server {
    server_name my.domain.com;
    ....
}
like image 60
big_water Avatar answered Nov 15 '22 14:11

big_water


Your are probably missing some Server Blocks (virtual hosts) files in the sites-enabled folder. Check if your config files exist in /etc/nginx/sites-available and /etc/nginx/sites-enabled. If they are not present in the sites-enabled folder, create symbolic links for them:

$ sudo ln -s /etc/nginx/sites-available/my.domain.com /etc/nginx/sites-enabled/

Add your site, check for config errors and restart nginx:

$ sudo certbot --nginx -d my.domain.com
$ sudo nginx -t
$ sudo service nginx restart
like image 25
Kurt Van den Branden Avatar answered Nov 15 '22 16:11

Kurt Van den Branden