Question

Trouble w/ Certbot & Let's Encrypt on Nginx/Ubuntu14.04

I’m following these instructions to install Certbot and Let’s Encrypt on my droplet running Nginx and Ubuntu 14.04, but am hitting a snag.

When I get to the alpha plugin portion: certbot --nginx I get the following response:

    Saving debug log to /var/log/letsencrypt/letsencrypt.log
    No names were found in your configuration files. Please enter in your domain
    name(s) (comma and/or space separated)  (Enter 'c' to cancel):  

I enter my domain name, hit enter and get:

    Obtaining a new certificate
    Performing the following challenges:
    tls-sni-01 challenge for **MYDOMAINNAME**
    Cleaning up challenges
    Cannot find a VirtualHost matching domain **MYDOMAINNAME**.

I’m not sure how to get past this error. Here’s my sites-available server block:


    server {
    	listen 80 default_server;
    	listen [::]:80 default_server ipv6only=on;
    	
    	root /usr/share/nginx/html;
    	index index.html index.htm;
    
    	# Make site accessible from http://localhost/
    	server_name localhost;
    
    	location ~ /.well-known {
    		allow all;
    		root /usr/share/nginx/html;
    	}
    
    	location / {
    		
    		# First attempt to serve request as file, then
    		# as directory, then fall back to displaying a 404.
    		try_files $uri $uri/ =404;
    		# Uncomment to enable naxsi on this location
    		# include /etc/nginx/naxsi.rules
    	}
    }

Any ideas where I’m going wrong?


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Turns out I needed to add a server block to nginx.conf and not just sites-available:

server {
listen 80;
server_name MYDOMAIN;
}

Running the process after that worked!

Hi @marketing8b7cf186d951e4e8d

In your server block, this is your problem server_name localhost; That should be your domain, something like this:

server_name example.com www.example.com;

Then test Nginx and restart it by running this command:

sudo service nginx configtest
sudo service nginx restart

Then run certbot --nginx again and use example.com www.example.com as domain.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel