让我们用Traefik加密吧

时间:2018-02-08 12:53:30

标签: lets-encrypt traefik

我尝试使用Let's Encrypt with Traefik,但这里是Traefik的日志:

Looking for provided certificate to validate [rancher.foo.bar]...
No provided certificate found for domains [rancher.foo.bar], get ACME certificate.
Looking for an existing ACME challenge for rancher.foo.bar...
No certificate found or generated for rancher.foo.bar
http2: server: error reading preface from client 1.2.3.4:60876: remote error: tls: unknown certificate authority

这是我的配置:

traefikLogsFile = "/tmp/traefik.log"
logLevel = "DEBUG" # DEBUG, INFO, WARN, ERROR, FATAL, PANIC
[accessLog]
filePath = "/tmp/access.log"


[entryPoints]
  [entryPoints.http]
  address = ":80"
    [entryPoints.https]
    address = ":443"
      [entryPoints.https.tls]

# Enable ACME (Let's Encrypt): automatic SSL.
[acme]
email = "foo@foo.bar"
storage = "/tmp/acme.json"
entryPoint = "https"
onHostRule = true
[acme.httpChallenge]
entryPoint = "http"


[api]
entryPoint = "traefik"
dashboard = true


[docker]
endpoint = "unix:///var/run/docker.sock"
domain = "foo.bar"
watch = true
exposedbydefault = true
usebindportip = true
swarmmode = false

Traefik提供商:

{
  "docker": {
    "backends": {
      "backend-rancher": {
        "servers": {
          "server-rancher": {
            "url": "http://172.17.0.3:8080",
            "weight": 0
          }
        },
        "loadBalancer": {
          "method": "wrr"
        }
      }
    },
    "frontends": {
      "frontend-Host-rancher-foo-bar-0": {
        "entryPoints": [
          "http"
        ],
        "backend": "backend-rancher",
        "routes": {
          "route-frontend-Host-rancher-foo-bar-0": {
            "rule": "Host:rancher.foo.bar"
          }
        },
        "passHostHeader": true,
        "priority": 0,
        "basicAuth": []
      }
    }
  }
}

怎么了?
感谢

2 个答案:

答案 0 :(得分:3)

您使用onHostRule,这将通过主机规则为每个前端请求Let的加密证书。但是您需要将您的前端分配到ACME的TLS入口点。 (这里https)。

因此,在您的docker标签中,您需要在frontend.entrypoint上添加https

答案 1 :(得分:1)

你可以补充一下:

defaultEntryPoints = ["http", "https"]

位于TOML文件的顶部。