Sign inSign up

vlauciani/nginx-certbot

By vlauciani

•Updated 4 months ago

Nginx with Certbot

Image
0

1.8K

vlauciani/nginx-certbot repository overview

License GitHub issues

Docker build Docker Image Size (latest semver) Docker Pulls

CI GitHub

⁠nginx-certbot

⁠Getting started

⁠Run container

Run container in daemon mode (see below for ENVIRONMENTS details):

docker run -d \
    --restart always \
    -p80:80 \
    -p443:443 \
    --name nginx-certbot \
    -e [email protected] \
    -e [email protected] \
    -e HOST_SMTP=smtp.example.com \
    -e CERTBOT_ENABLE_RENEW=1 \
    -e CERTBOT_CA_HOST=https://acme-v02.harica.gr/acme/... \
    -v $(pwd)/volumes/etc/letsencrypt:/etc/letsencrypt \
    vlauciani/nginx-certbot

ONLY FIRST TIME you need to register ACME account into the nginx-certbot running container:

docker exec -it nginx-certbot certbot register --server https://acme-v02.harica.gr/acme/... --email <email> --eab-kid <eab-kid> --eab-hmac-key <eab-hmac-key>

Get the certificate, install it, and automatically restart Nginx (the server_name in the Nginx configuration must match the domain specified with --domain option):

docker exec -it nginx-certbot certbot --nginx --non-interactive --server https://acme-v02.harica.gr/acme/... -v --cert-name <cert_name> --domain <domain>
⁠Environment variable

With environment variables you can set:

  1. CERTBOT_ENABLE_RENEW=1 (default 0): execute every 12h
  2. CERTBOT_ENABLE_RENEW_SEND_EMAIL=1 (default 0): used to send en e-mail on each renew
  3. HOST_SMTP=smtp.example.com (default not set): It is used to set SMTP host to send an email at each renew; Works only on port 25.
  4. [email protected] (default not set): Set the sender
  5. [email protected] (default not set): Set the receiver
  6. CERTBOT_CA_HOST=https://acme-v02.harica.gr/acme/... (default not set): Set CA Remote server
⁠Manual operations
⁠renew certificate
docker exec -it nginx-certbot certbot renew --server https://acme-v02.harica.gr/acme/... -v
⁠revoke certificate
docker exec -it nginx-certbot certbot revoke --server https://acme-v02.harica.gr/acme/... -v --cert-name <cert_name>
⁠delete certificate
docker exec -it nginx-certbot certbot delete --server https://acme-v02.harica.gr/acme/... -v --cert-name <cert_name>
⁠Build docker images by yourself

Instead of using the pre-built docker image, you can build the Docker image by yourself:

docker build -t vlauciani/nginx-certbot .
⁠Use in docker compose

Example:

services:
  nginx: 
    image: vlauciani/nginx-certbot:latest
    restart: always
    volumes:
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf
      - ./nginx/conf.d:/etc/nginx/conf.d
      - ./letsencrypt:/etc/letsencrypt
    ports:
      - 443:443
    environment:
      - CERTBOT_ENABLE_RENEW=1
      - CERTBOT_ENABLE_RENEW_SEND_EMAIL=1
      - HOST_SMTP=ssmail.rm.ingv.it
      - [email protected]
      - [email protected]
      - CERTBOT_CA_HOST=https://acme-v02.harica.gr/acme/...

⁠Contribute

Thanks to your contributions!

Here is a list of users who already contributed to this repository:
⁠

Tag summary

Content type

Image

Digest

sha256:cd7d74343…

Size

114.6 MB

Last updated

4 months ago

docker pull vlauciani/nginx-certbot