Dump ACME data from Traefik to certificates
Go to file
2020-05-18 03:13:41 +03:00
.github chore: add funding ♥ 2020-05-09 15:47:17 +02:00
cmd chore: update linter. 2020-05-09 15:50:40 +02:00
docs feat: support etcd v3. 2019-10-09 03:08:33 +02:00
dumper chore: update linter. 2020-05-09 15:50:40 +02:00
hook fix: multiple resolvers. 2019-09-30 14:51:30 +02:00
integrationtest fix: clean file path. 2020-02-16 20:26:48 +01:00
.dockerignore chore: migrate to seihon. 2019-04-30 23:05:08 +02:00
.gitignore chore: migrate to seihon. 2019-04-30 23:05:08 +02:00
.golangci.toml chore: update linter. 2020-05-09 15:50:40 +02:00
.goreleaser.yml chore: update goreleaser config. 2019-08-01 08:11:06 +02:00
.travis.yml chore(deps): bump github.com/containous/traefik/v2 from 2.1.6 to 2.2.0 (#82) 2020-03-26 13:33:35 +01:00
Dockerfile chore: update to alpine 3.10 2019-09-06 02:48:51 +02:00
go.mod chore(deps): bump github.com/go-acme/lego/v3 from 3.6.0 to 3.7.0 (#91) 2020-05-12 11:03:40 +02:00
go.sum chore(deps): bump github.com/go-acme/lego/v3 from 3.6.0 to 3.7.0 (#91) 2020-05-12 11:03:40 +02:00
godownloader.sh chore: adds download script. 2019-04-04 21:29:26 +02:00
LICENSE chore: adds License. 2019-02-11 05:29:33 +01:00
main.go chore: prepare release v2.0.0 2019-04-20 22:24:57 +02:00
Makefile feat: support Traefik v2. 2019-09-01 19:20:29 +02:00
readme.md Add docker-compose example 2020-05-18 03:13:41 +03:00
tmpl.Dockerfile chore: migrate to seihon. 2019-04-30 23:05:08 +02:00

traefik-certs-dumper

GitHub release Build Status Docker Information Go Report Card

If you appreciate this project:

Sponsor

Features

  • Supported sources:
    • file ("acme.json")
    • KV stores (Consul, Etcd, Zookeeper, Boltdb)
  • Watch changes:
    • from file ("acme.json")
    • from KV stores (Consul, Etcd, Zookeeper)
  • Output formats:
    • use domain as sub-directory (allow custom names and extensions)
    • flat (domain as filename)
  • Hook (only with watch mode and if the data source changes)

Installation

Download / CI Integration

curl -sfL https://raw.githubusercontent.com/ldez/traefik-certs-dumper/master/godownloader.sh | bash -s -- -b $GOPATH/bin v2.7.0

From Binaries

You can use pre-compiled binaries:

  • To get the binary just download the latest release for your OS/Arch from the releases page
  • Unzip the archive.
  • Add traefik-certs-dumper in your PATH.

From Docker

docker run ldez/traefik-certs-dumper:<tag_name>

Usage

Examples

Note: to dump data from Traefik v2, the CLI flag --version v2 must be added.

docker-compose

docker-compose.yml:

version: '3'

services:
    traefik:
        image: traefik:1.7
        command:
            --entryPoints='Name:http Address::80'
            --entryPoints='Name:https Address::443 TLS'
            --defaultentrypoints=http,https
            --logLevel=DEBUG
            --docker
            --docker.exposedByDefault=false
            --acme
            --acme.acmeLogging=true
            --acme.entrypoint=https
            --acme.storage=/data/acme.json
            --acme.onHostRule=true
            --acme.httpChallenge.entryPoint=http
        ports:
            - 8001:80
            - 8002:443
        volumes:
            - /var/run/docker.sock:/var/run/docker.sock
            - .:/data

    traefik-certs-dumper:
        image: ldez/traefik-certs-dumper:v2.7.0
        entrypoint: sh -c '
            apk add jq
            ; while ! [ -e /data/acme.json ]
                || ! [ `jq ".Certificates | length" /data/acme.json` != 0 ]; do
                    sleep 1
                ; done
            && traefik-certs-dumper file --watch 
                --source /data/acme.json --dest /data/certs'
        volumes:
            - .:/data

    whoami:
        image: containous/whoami
        labels:
            traefik.enable: true
            traefik.frontend.rule: Host:example.com

traefik ports are published to 8001 and 8002. It's assumed here that you need certificates as separate files because you want to put traefik behind another proxy.

Simple Dump

$ traefik-certs-dumper file
dump
├──certs
│  └──my.domain.com.key
└──private
   ├──my.domain.com.crt
   └──letsencrypt.key

Change source and destination

$ traefik-certs-dumper file --source ./acme.json --dest ./dump/test
test
├──certs
│  └──my.domain.com.key
└──private
   ├──my.domain.com.crt
   └──letsencrypt.key

Use domain as sub-directory

$ traefik-certs-dumper file --domain-subdir=true
dump
├──my.domain.com
│  ├──certificate.crt
│  └──privatekey.key
└──private
   └──letsencrypt.key

Change file extension

$ traefik-certs-dumper file --domain-subdir --crt-ext=.pem --key-ext=.pem
dump
├──my.domain.com
│  ├──certificate.pem
│  └──privatekey.pem
└──private
   └──letsencrypt.key

Change file name

$ traefik-certs-dumper file --domain-subdir --crt-name=fullchain --key-name=privkey
dump
├──my.domain.com
│  ├──fullchain.crt
│  └──privkey.key
└──private
   └──letsencrypt.key

KV store

Consul

$ traefik-certs-dumper kv consul --endpoints localhost:8500

Etcd

$ traefik-certs-dumper kv etcd --endpoints localhost:2379

Boltdb

$ traefik-certs-dumper kv boltdb --endpoints /the/path/to/mydb.db

Zookeeper

$ traefik-certs-dumper kv zookeeper --endpoints localhost:2181