Hi all,
I'm trying to setup the creation and renewal of ssl-certificates with nginx and Let's Encrypt within Docker Compose using the following tutorial: Nginx and Let’s Encrypt with Docker in Less Than 5 Minutes | by Philipp | Medium
Unfortunately I am having troubles with generating the certificates as certbot fails to pass the acme-challenges. From the errors it seems that the location of the challenge is not reacheable. Therefore I have tried variations in the nginx.conf-file of the part that specifies where the challenge can be found (see below), but no success so far. From what I understand the ports (80, 443) are open as well.
location ^~ /.well-known/acme-challenge/ {
root /var/www/certbot;
}
Further details listed below. I have ommitted some parts, so let me know if you require more logs or information. Does anyone have an idea what else I can try? Many thanks for your help in advance!
My domain is:
xxxx.xxxx.com
I ran this command:
sudo ./init-letsencrypt.sh
The shell-script can be found here: https://raw.githubusercontent.com/wmnnd/nginx-certbot/master/init-letsencrypt.sh
And relevant params (keep staging=1 while testing):
domains=(xxxx.xxxx.com)
rsa_key_size=4096
data_path="./data/certbot"
email="xxx@xxxx.com" # Adding a valid address is strongly recommended
staging=1 # Set to 1 if you're testing your setup to avoid hitting request limits
nginx.conf:
upstream labeler {
server web:8000;
}
server {
listen 80 default_server;
return 444;
}
server {
listen 80;
listen [::]:80;
server_name xxxx.xxxx.com;
location ^~ /.well-known/acme-challenge/ {
root /var/www/certbot;
}
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name xxxx.xxxx.com;
# SSL
ssl_certificate /etc/letsencrypt/live/xxxx.xxxx.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/xxxx.xxxx.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
client_max_body_size 4G;
keepalive_timeout 5;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://labeler;
}
}
docker-compose.yml:
version: "3.8"
services:
(... db and web service ...)
nginx:
build:
context: .
dockerfile: Dockerfile.nginx
volumes:
- ./data/certbot/conf:/etc/letsencrypt
- ./data/certbot/www:/var/www/certbot
ports:
- 80:80
- 443:443
depends_on:
- web
certbot:
image: certbot/certbot
volumes:
- ./data/certbot/conf:/etc/letsencrypt
- ./data/certbot/www:/var/www/certbot
- ./log/letsencrypt:/var/log/letsencrypt
It produced this output:
Downloading recommended TLS parameters ...
Creating dummy certificate for xxxx.xxxx.com ...
Creating network "labeler_ssl_default" with the default driver
Creating labeler_ssl_certbot_run ... done
Generating a RSA private key
.......................................................................++++
.........................................................++++
writing new private key to '/etc/letsencrypt/live/xxxx.xxxx.com/privkey.pem'
-----
### Starting nginx ...
Creating labeler_ssl_db_1 ... done
Creating labeler_ssl_web_1 ... done
Creating labeler_ssl_nginx_1 ... done
### Deleting dummy certificate for xxxx.xxxx.com ...
Creating labeler_ssl_certbot_run ... done
### Requesting Let's Encrypt certificate for xxxx.xxxx.com ...
Creating labeler_ssl_certbot_run ... done
Saving debug log to /var/log/letsencrypt/letsencrypt.log
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing, once your first certificate is successfully issued, to
share your email address with the Electronic Frontier Foundation, a founding
partner of the Let's Encrypt project and the non-profit organization that
develops Certbot? We'd like to send you email about our work encrypting the web,
EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: N
Account registered.
Requesting a certificate for xxxx.xxxx.com
Certbot failed to authenticate some domains (authenticator: webroot). The Certificate Authority reported these problems:
Domain: xxxx.xxxx.com
Type: unauthorized
Detail: Invalid response from https://xxxx.xxxx.com/.well-known/acme-challenge/D6IBfwJy0Ja8eahYrQxSYsd49YERRZ43wRrmxlN0IcA [xxx.xxx.xxx.xxx]: "\n<!doctype html>\n<html lang=\"en\">\n<head>\n <title>Not Found</title>\n</head>\n<body>\n <h1>Not Found</h1><p>The requested resource"
Hint: The Certificate Authority failed to download the temporary challenge files created by Certbot. Ensure that the listed domains serve their content from the provided --webroot-path/-w and that files created there can be downloaded from the internet.
Some challenges have failed.
Ask for help or search for solutions at https://community.letsencrypt.org. See the logfile /var/log/letsencrypt/letsencrypt.log or re-run Certbot with -v for more details.
ERROR: 1
letsenscrypt-log (let me know if you need more as the actual log is larger):
2021-06-15 08:12:09,338:DEBUG:urllib3.connectionpool:https://acme-staging-v02.api.letsencrypt.org:443 "POST /acme/authz-v3/68900668 HTTP/1.1" 200 1628
2021-06-15 08:12:09,339:DEBUG:acme.client:Received response:
HTTP 200
Server: nginx
Date: Tue, 15 Jun 2021 08:12:09 GMT
Content-Type: application/json
Content-Length: 1628
Connection: keep-alive
Boulder-Requester: 19908234
Cache-Control: public, max-age=0, no-cache
Link: <https://acme-staging-v02.api.letsencrypt.org/directory>;rel="index"
Replay-Nonce: 0002tjlTExLwv4QVd8EzEb6xOE1y8--YnxeWcgS8xc1kDXk
X-Frame-Options: DENY
Strict-Transport-Security: max-age=604800
{
"identifier": {
"type": "dns",
"value": "xxxx.xxxx.com"
},
"status": "invalid",
"expires": "2021-06-22T08:12:03Z",
"challenges": [
{
"type": "http-01",
"status": "invalid",
"error": {
"type": "urn:ietf:params:acme:error:unauthorized",
"detail": "Invalid response from https://xxxx.xxxx.com/.well-known/acme-challenge/D6IBfwJy0Ja8eahYrQxSYsd49YERRZ43wRrmxlN0IcA [xxx.xxx.xxx.xxx]: \"\\n\u003c!doctype html\u003e\\n\u003chtml lang=\\\"en\\\"\u003e\\n\u003chead\u003e\\n \u003ctitle\u003eNot Found\u003c/title\u003e\\n\u003c/head\u003e\\n\u003cbody\u003e\\n \u003ch1\u003eNot Found\u003c/h1\u003e\u003cp\u003eThe requested resource\"",
"status": 403
},
"url": "https://acme-staging-v02.api.letsencrypt.org/acme/chall-v3/68900668/CJxahw",
"token": "D6IBfwJy0Ja8eahYrQxSYsd49YERRZ43wRrmxlN0IcA",
"validationRecord": [
{
"url": "http://xxxx.xxxx.com/.well-known/acme-challenge/D6IBfwJy0Ja8eahYrQxSYsd49YERRZ43wRrmxlN0IcA",
"hostname": "xxxx.xxxx.com",
"port": "80",
"addressesResolved": [
"xxx.xxx.xxx.xxx"
],
"addressUsed": "xxx.xxx.xxx.xxx"
},
{
"url": "https://xxxx.xxxx.com/.well-known/acme-challenge/D6IBfwJy0Ja8eahYrQxSYsd49YERRZ43wRrmxlN0IcA",
"hostname": "xxxx.xxxx.com",
"port": "443",
"addressesResolved": [
"xxx.xxx.xxx.xxx"
],
"addressUsed": "xxx.xxx.xxx.xxx"
}
],
"validated": "2021-06-15T08:12:04Z"
}
]
}
2021-06-15 08:12:09,340:DEBUG:acme.client:Storing nonce: 0002tjlTExLwv4QVd8EzEb6xOE1y8--YnxeWcgS8xc1kDXk
2021-06-15 08:12:09,340:INFO:certbot._internal.auth_handler:Challenge failed for domain xxxx.xxxx.com
2021-06-15 08:12:09,340:INFO:certbot._internal.auth_handler:http-01 challenge for xxxx.xxxx.com
2021-06-15 08:12:09,341:DEBUG:certbot.display.util:Notifying user:
Certbot failed to authenticate some domains (authenticator: webroot). The Certificate Authority reported these problems:
Domain: xxxx.xxxx.com
Type: unauthorized
Detail: Invalid response from https://xxxx.xxxx.com/.well-known/acme-challenge/D6IBfwJy0Ja8eahYrQxSYsd49YERRZ43wRrmxlN0IcA [xxx.xxx.xxx.xxx]: "\n<!doctype html>\n<html lang=\"en\">\n<head>\n <title>Not Found</title>\n</head>\n<body>\n <h1>Not Found</h1><p>The requested resource"
Hint: The Certificate Authority failed to download the temporary challenge files created by Certbot. Ensure that the listed domains serve their content from the provided --webroot-path/-w and that files created there can be downloaded from the internet.
nginx-log:
nginx_1 | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
nginx_1 | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
nginx_1 | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
nginx_1 | 10-listen-on-ipv6-by-default.sh: info: /etc/nginx/conf.d/default.conf is not a file or does not exist
nginx_1 | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
nginx_1 | /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
nginx_1 | /docker-entrypoint.sh: Configuration complete; ready for start up
nginx_1 | 2021/06/15 08:11:50 [notice] 1#1: using the "epoll" event method
nginx_1 | 2021/06/15 08:11:50 [notice] 1#1: nginx/1.21.0
nginx_1 | 2021/06/15 08:11:50 [notice] 1#1: built by gcc 10.2.1 20201203 (Alpine 10.2.1_pre1)
nginx_1 | 2021/06/15 08:11:50 [notice] 1#1: OS: Linux 5.4.0-48-generic
nginx_1 | 2021/06/15 08:11:50 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
nginx_1 | 2021/06/15 08:11:50 [notice] 1#1: start worker processes
nginx_1 | 2021/06/15 08:11:50 [notice] 1#1: start worker process 21
nginx_1 | 2021/06/15 08:11:50 [notice] 1#1: start worker process 22
nginx_1 | 2021/06/15 08:11:50 [notice] 1#1: start worker process 23
nginx_1 | 2021/06/15 08:11:50 [notice] 1#1: start worker process 24
nginx_1 | 18.196.102.134 - - [15/Jun/2021:08:12:05 +0000] "GET /.well-known/acme-challenge/D6IBfwJy0Ja8eahYrQxSYsd49YERRZ43wRrmxlN0IcA HTTP/1.1" 301 169 "-" "Mozilla/5.0 (compatible; Let's Encrypt validation server; +https://www.letsencrypt.org)" "-"
nginx_1 | 18.196.102.134 - - [15/Jun/2021:08:12:05 +0000] "GET /.well-known/acme-challenge/D6IBfwJy0Ja8eahYrQxSYsd49YERRZ43wRrmxlN0IcA HTTP/1.1" 404 179 "http://xxxx.xxxx.com/.well-known/acme-challenge/D6IBfwJy0Ja8eahYrQxSYsd49YERRZ43wRrmxlN0IcA" "Mozilla/5.0 (compatible; Let's Encrypt validation server; +https://www.letsencrypt.org)" "-"
nginx_1 | 66.133.109.36 - - [15/Jun/2021:08:12:05 +0000] "GET /.well-known/acme-challenge/D6IBfwJy0Ja8eahYrQxSYsd49YERRZ43wRrmxlN0IcA HTTP/1.1" 301 169 "-" "Mozilla/5.0 (compatible; Let's Encrypt validation server; +https://www.letsencrypt.org)" "-"
nginx_1 | 3.143.223.150 - - [15/Jun/2021:08:12:05 +0000] "GET /.well-known/acme-challenge/D6IBfwJy0Ja8eahYrQxSYsd49YERRZ43wRrmxlN0IcA HTTP/1.1" 301 169 "-" "Mozilla/5.0 (compatible; Let's Encrypt validation server; +https://www.letsencrypt.org)" "-"
nginx_1 | 3.143.223.150 - - [15/Jun/2021:08:12:06 +0000] "GET /.well-known/acme-challenge/D6IBfwJy0Ja8eahYrQxSYsd49YERRZ43wRrmxlN0IcA HTTP/1.1" 404 179 "http://xxxx.xxxx.com/.well-known/acme-challenge/D6IBfwJy0Ja8eahYrQxSYsd49YERRZ43wRrmxlN0IcA" "Mozilla/5.0 (compatible; Let's Encrypt validation server; +https://www.letsencrypt.org)" "-"
nginx_1 | 66.133.109.36 - - [15/Jun/2021:08:12:06 +0000] "GET /.well-known/acme-challenge/D6IBfwJy0Ja8eahYrQxSYsd49YERRZ43wRrmxlN0IcA HTTP/1.1" 404 179 "http://xxxx.xxxx.com/.well-known/acme-challenge/D6IBfwJy0Ja8eahYrQxSYsd49YERRZ43wRrmxlN0IcA" "Mozilla/5.0 (compatible; Let's Encrypt validation server; +https://www.letsencrypt.org)" "-"
My web server is (include version):
nginx/1.21.0
The operating system my web server runs on is (include version):
Alpine Linux 3.13
My hosting provider, if applicable, is:
transip
I can login to a root shell on my machine (yes or no, or I don't know):
yes
I'm using a control panel to manage my site (no, or provide the name and version of the control panel):
no
The version of my client is (e.g. output of certbot --version
or certbot-auto --version
if you're using Certbot):
1.16.0