I’m having trouble generating a Lets Encrypt certificate for my site.
I am running on nginx, Ubuntu 16.04, on Digital ocean. I have a docker container with my API and a docker container with nginx on it.
I can access a sample file here: http://www.api.pebblesofhope.org/.well-known/acme-challenge/test/sample.txt
but can’t generate a certificate.
Error message:
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for api.pebblesofhope.org
http-01 challenge for www.api.pebblesofhope.org
Using the webroot path /data/letsencrypt for all unmatched domains.
Waiting for verification...
Cleaning up challenges
Failed authorization procedure. api.pebblesofhope.org (http-01): urn:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response from http://api.pebblesofhope.org/.well- known/acme-challenge/57bhfNUkRT6h3DG9wGa5kb1RedAP8cYkAoEmUKWoanc: "<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>", www.api.pebblesofhope.org (http-01): urn:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response from http://www.api.pebblesofhope.org/.well- known/acme-challenge/6UHtRe8UR1UfFC3gtp4HKVuTqxc1wPJM1IO8LRZ0ffA: "<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>"
IMPORTANT NOTES:
- The following errors were reported by the server:
Domain: api.pebblesofhope.org
Type: unauthorized
Detail: Invalid response from
http://api.pebblesofhope.org/.well-known/acme-challenge/57bhfNUkRT6h3DG9wGa5kb1RedAP8cYkAoEmUKWoanc:
"<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>"
Domain: www.api.pebblesofhope.org
Type: unauthorized
Detail: Invalid response from
http://www.api.pebblesofhope.org/.well-known/acme-challenge/6UHtRe8UR1UfFC3gtp4HKVuTqxc1wPJM1IO8LRZ0ffA:
"<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>"
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.
Command to generate certificate:
docker run -it --rm -v certs:/etc/letsencrypt -v certs-data:/data/letsencrypt deliverous/certbot certonly --webroot --staging --agree-tos -w /data/letsencrypt -d api.pebblesofhope.org -d www.api.pebblesofhope.org
Nginx config file:
server {
listen 80;
server_name api.pebblesofhope.org www.api.pebblesofhope.org;
location ^~ /.well-known {
allow all;
root /data/letsencrypt/;
}
location / {
proxy_pass http://poh-api:3000;
}
}
Nginx -T result:
# configuration file /etc/nginx/nginx.conf:
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
# configuration file /etc/nginx/conf.d/default.conf:
server {
listen 80;
server_name api.pebblesofhope.org www.api.pebblesofhope.org;
location ^~ /.well-known {
allow all;
root /data/letsencrypt/;
}
location / {
proxy_pass http://poh-api:3000;
}
}