Run the following commands from docker/. The optional certbot profile obtains and renews certificates when you invoke its update script; it does not schedule renewals automatically.
- Get letsencrypt certs
set.envvaluesexecute command:NGINX_SSL_CERT_FILENAME=fullchain.pem NGINX_SSL_CERT_KEY_FILENAME=privkey.pem NGINX_ENABLE_CERTBOT_CHALLENGE=true CERTBOT_DOMAIN=your_domain.com CERTBOT_EMAIL=example@your_domain.com
then after the containers launched:docker compose --profile certbot up --force-recreate -d
docker compose exec -it certbot /bin/sh /update-cert.sh - Edit
.envfile anddocker compose --profile certbot upagain.
set.envvalue additionallyexecute command:NGINX_HTTPS_ENABLED=trueThen you can access your server with HTTPS.docker compose --profile certbot up -d --no-deps --force-recreate nginx
https://your_domain.com
For SSL certificates renewal, execute commands below:
docker compose exec -it certbot /bin/sh /update-cert.sh
docker compose exec nginx nginx -s reloadCERTBOT_OPTIONS key might be helpful for testing. i.e.,
CERTBOT_OPTIONS=--dry-runTo apply changes to CERTBOT_OPTIONS, regenerate the certbot container before updating the certificates.
docker compose --profile certbot up -d --no-deps --force-recreate certbot
docker compose exec -it certbot /bin/sh /update-cert.shThen, reload the nginx container if necessary.
docker compose exec nginx nginx -s reloadTo use cert files dir nginx/ssl as before, simply launch containers WITHOUT --profile certbot option.
docker compose up -d