Skip to content

Conversation

@andrius
Copy link

@andrius andrius commented Oct 25, 2020

In some my project I do need to fully automate SSL certificate creation without user intervention. Idea is to move init-letsencrypt.sh and tune up scripts so initial certificates will be created automatically.

Steps:

  • Update docker-compose.yml or create a Dockerfile so certbot service won't start without "healthy" nginx service;
  • Create a Dockerfile for nginx service, add a docker-entrypoint.sh, that replicate most of the init-letsencrypt.sh logic:
    • Create new SSL for first run (by checking for a files presence in the certain folder);
    • Start nginx linux service and remove created SSL certificate right after that;
    • Wait for certbot docker service and request certificate first time;
    • domain, email and other user-data should be available through environment variable (introduce .env file;
  • Update README.md.

@andrius andrius marked this pull request as draft October 25, 2020 15:11
- Created `Dockerfile` for nginx;
- Downloading `options-ssl-nginx.conf` and `ssl-dhparams.pem` during
  docker build phase;
- Relevant part in the `app.conf` updated;
- Creating temp SSL certificate through `docker-entrypoint.sh` when
  nginx service is starting;
- certbot container waiting for healthy nginx container;
- during startup of the nginx container:
    - an initial certificate get created;
    - it starts nginx daemon and await for the certbot container, then
      removing temporally certificate;
    - it does start a "API" that allow certbot to reload nginx daemon;
-
@andrius andrius marked this pull request as ready for review November 2, 2020 16:28
@bzgec
Copy link

bzgec commented Apr 15, 2021

Is there a plan to accept this pull request?

@zx1986
Copy link

zx1986 commented May 28, 2022

if domains were an array, the init-letsencrypt.sh will failed, it just handled the first domain in array.

### no for loop here.

echo "### Creating dummy certificate for $domains ..."

path="/etc/letsencrypt/live/$domains"
mkdir -p "$data_path/conf/live/$domains"

docker-compose run --rm --entrypoint "\
  openssl req -x509 -nodes -newkey rsa:$rsa_key_size -days 1\
    -keyout '$path/privkey.pem' \
    -out '$path/fullchain.pem' \
    -subj '/CN=localhost'" certbot
echo

@mzbik
Copy link

mzbik commented Jan 5, 2023

Also need to update README.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants