Nginx – Error installing LetsEncrypt SSL: (http-01): urn:acme:error:connection :: The server could not connect to the client to verify the domain

lets-encryptnginxsslssl-certificate

I am trying to install LetsEncrypt on my server (which I have root SSH access to), for staging.dnslaude.com – which is a publicly accessible domain, pointing to 213.212.81.89.

The server is running ubuntu 16.04, and an nginx web-server. Below is the nginx config:

server {
  listen 80;
  server_name staging.dnslaude.com;

  root /path/to/webroot;

  location ^~ /.well-known/acme-challenge/ {
    try_files $uri $uri/ =404;
  }
  rewrite ^(.*) https://$host$1 permanent;
}

server {
  listen 443;
  ssl on;
  ssl_certificate /path/to/self/signed/certificate.crt;
  ssl_certificate_key /path/to/key.key;

  server_name staging.dnslaude.com;

  root /path/to/webroot;

  # ....

  location ^~ /.well-known/acme-challenge/ {
    try_files $uri $uri/ =404;
  }
}

You can see that the nginx config appears to work, as I have manually placed a file in the acme-challenge folder here.

However, when I run the command:

letsencrypt certonly --webroot -w /path/to/webroot -d staging.dnslaude.com

It returns the following error:

Failed authorization procedure. staging.dnslaude.com (http-01):
urn:acme:error:connection :: The server could not connect to the
client to verify the domain :: Could not connect to
staging.dnslaude.com

IMPORTANT NOTES:
– The following errors were reported by the server:

Domain: staging.dnslaude.com Type: connection Detail: Could
not connect to staging.dnslaude.com

To fix these errors, please make sure that your domain name was
entered correctly and the DNS A record(s) for that domain
contain(s) the right IP address. Additionally, please check that
your computer has a publicly routable IP address and that no
firewalls are preventing the server from communicating with the
client. If you're using the webroot plugin, you should also verify
that you are serving files from the webroot path you provided.

I followed the basic setup guide outlined here, and have tried all sorts of configuration variations, such as those suggested here. However, I cannot get past the above error – and cannot see anything in a log file to indicate the cause.

Any suggestions?

Best Answer

Your nginx config looks correct.

On a hunch, I ran nmap against your domain (since you included it in your question); it would appear that you are currently filtering port 80, so there is no way for LetsEncrypt to connect externally and verify.

You'll need to make sure that port 80 is made externally accessible on the local firewall of the server in question (as well as any ACLs which might be in place on a vhost provider or similar).