DenCowboy
DenCowboy

Reputation: 15066

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

Upvotes: 9

Views: 7243

Answers (2)

Kurt Van den Branden
Kurt Van den Branden

Reputation: 12934

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

Upvotes: 2

big_water
big_water

Reputation: 3204

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;
    ....
}

Upvotes: 10

Related Questions