9

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

certbot-auto --nginx -d my.domain.com -n --agree-tos --email admin@mail.com

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

DenCowboy
  • 13,884
  • 38
  • 114
  • 210
  • The error refers to your nginx config, not DNS/IP etc. There were [issues](https://github.com/certbot/certbot/issues/3798) with the nginx config parsers that are due to be solved. – neo post modern Apr 03 '17 at 10:05
  • Can you post your nginx sites-enabled config? should be located here if you're using Linux Ubuntu server -> /etc/nginx/sites-enabled/default – big_water Jun 01 '17 at 13:53

2 Answers2

10

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;
    ....
}
big_water
  • 3,024
  • 2
  • 26
  • 44
2

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
Kurt Van den Branden
  • 11,995
  • 10
  • 76
  • 85