Hi guys,
To continue the discussion, I will explain exactly what I’m trying to achive: run 2 docker containers, one nginx and another certbot.
i have a shared volume between the 2 containers that exposes the /etc/letsencrypt/ from certbot and /home/www/letsencrypt from nginx to the same folder on my host.
i want to use a single nginx.conf in the nginx container for an entire list of domains but for that as you said above, i need a bit of scripting. so as far as i understand i need a “clean/standard” nginx server block text for each new added domain to the nginx.conf file, something like the below for running in parallel the certbot container and to generate the ssl certs:
server {
listen 80;
listen [::]:80;
server_name domain.com;
location ^~ /.well-known/acme-challenge/ {
default_type “text/plain”;
root /home/www/letsencrypt;
allow all;
location / {
try_files $uri $uri/ =404;
}
after using the above, i need to include in the nginx.conf a snippet or the lines that are usually generated by cerbot:
listen 443 ssl;
ssl_certificate /home/www/letsencrypt/live/domain.com/fullchain.pem;
ssl_certificate_key /home/www/letsencrypt/live/domain.com/privkey.pem;
and then reload the nginx service.
my docker-compose.yml file looks like this:
version: “3.2”
services:
certbot:
image: certbot/certbot
container_name: certbot
volumes:
- /home/certbot:/etc/letsencrypt
command: certonly --webroot -n -w /etc/letsencrypt -d domain.com --text --agree-tos --email blabla@testing.com --server https://acme-staging.api.letsencrypt.org/directory --rsa-key-size 4096 --verbose
nginx:
image: nginx
container_name: nginx
ports:
- “80:80”
- "443:443"
volumes:
- /home/certbot:/home/www/letsencrypt
- ./nginx/:/etc/nginx/conf.d/
am i missing something? because nginx should be able to serve the files from the shared volume so certbot can pass the challange but i am still getting the below error:
certbot | Connection refused
certbot |
certbot | To fix these errors, please make sure that your domain name was
certbot | entered correctly and the DNS A/AAAA record(s) for that domain
certbot | contain(s) the right IP address. Additionally, please check that
certbot | your computer has a publicly routable IP address and that no
certbot | firewalls are preventing the server from communicating with the
certbot | client. If you’re using the webroot plugin, you should also verify
certbot | that you are serving files from the webroot path you provided.
LE: the issue was that i was trying to generate the ssl certs for a domain but the server i was running the challage on, was hosted on a different domain so it obviously didn’t work…
anyway, i would gladly receive a review for the above solution from your part.
thanks!