Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Letsencrypt + Docker + Nginx

Tags:

docker

nginx

ssl

I am referring this link https://miki725.github.io/docker/crypto/2017/01/29/docker+nginx+letsencrypt.html to enable SSL on my app which is running along with docker. So the problem here is when I run the below command

  docker run -it --rm \
  -v certs:/etc/letsencrypt \
  -v certs-data:/data/letsencrypt \
  deliverous/certbot \
  certonly \
  --webroot --webroot-path=/data/letsencrypt \
  -d api.mydomain.com

It throws an error:

Failed authorization procedure. api.mydomain.com (http-01): urn:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response from http://api.mydomain.com/.well-known/acme-challenge/OCy4HSmhDwb2dtBEjZ9vP3HgjVXDPeghSAdqMFOFqMw:

So can any one please help me and let me know if I am missing something or doing something wrong.

like image 574
Gaurav Soni Avatar asked Mar 01 '26 05:03

Gaurav Soni


1 Answers

What seems to be missing from that article and possibly from your setup is that the hostname api.mydomain.com needs to have a public DNS record pointing to the IP address of the machine on which the Nginx container is running.

The Let's Encrypt process is trying to access the file api.mydomain.com/.well-known/acme-challenge/OCy4HSmhDwb2dtBEjZ9vP3HgjVXDPeghSAdqMFOFqMw. This file is put there by certbot. If the address api.mydomain.com does not resolve to the address of the machine from which you are running certbot then the process will fail.

You will also need to have ports 80 and 443 open for it to work.

Based on the available info that is my best suggestion on where you can start looking to resolve the issue.

like image 57
Yuri L Avatar answered Mar 02 '26 19:03

Yuri L



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!