Traefik初始化在带有acme.json的docker容器中失败。 “在创建TLS配置时收到错误:私钥为nil”

时间:2019-05-11 14:08:35

标签: docker kubernetes docker-compose traefik

我尝试使用acme.json设置Traefik,但是在容器启动时出现以下错误

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 traefix配置文件:

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

1 个答案:

答案 0 :(得分:0)

根据文档,您还可以将“ tls证书”放置在全局配置文件 traefik.toml 中,而不是:

[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"

您可以在here以及stackoverflow here中找到更多信息。

请也遵循此tutorial