Traefik initialization is failed in docker container with acme.json . "Receiving Error creating TLS config: private key was nil"

5/11/2019

I have tried to setup Traefik with acme.json but upon the container startup I am getting following errors

level=error msg="Cannot unmarshall private key []"
level=error msg="Error creating TLS config: private key was nil"
level=fatal msg="Error preparing server: private key was nil"


docker run -d \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v $PWD/traefik.toml:/traefik.toml \
  -v $PWD/acme.json:/acme.json \
  -p 80:80 \
  -p 443:443 \
  -l traefik.frontend.rule=Host:abc.com\
  -l traefik.port=8080 \
  --network proxy \
  --name traefik \
  traefik:1.3.6-alpine --docker

traefik.toml the traefix configuration file:

defaultEntryPoints = ["http", "https"]
[web]
address = ":8080"
  [web.auth.basic]
  users = ["admin:$apr1$fwifc.Nx$xfuaGzJ6Jzdf347PQzxD95"]

[entryPoints]
  [entryPoints.http]
  address = ":80"
    [entryPoints.http.redirect]
          entryPoint = "https"
  [entryPoints.https]
  address = ":443"
    [entryPoints.https.tls]
[acme]
email = "abc@msn.com"
storage = "acme.json"
entryPoint = "https"
onHostRule = true
onDemand = false
-- Zain Malik
docker
docker-compose
kubernetes
traefik

1 Answer

5/13/2019

As per documentation you can also place your "tls certificates" in the global configuration file traefik.toml instead like:

[entryPoints.https.tls]
      [[entryPoints.https.tls.certificates]]
      CertFile = "integration/fixtures/https/snitest.com.cert"
      KeyFile = "integration/fixtures/https/snitest.com.key"
      [[entryPoints.https.tls.certificates]]
      CertFile = "integration/fixtures/https/snitest.org.cert"
      KeyFile = "integration/fixtures/https/snitest.org.key"

You can find more information here and also in stackoverflow here.

Please follow also this tutorial.

-- Hanx
Source: StackOverflow