ACME证书因Traefik超时

时间:2020-02-02 19:01:40

标签: docker dns traefik

你好!

我在找出出现此错误的原因时遇到了问题。尝试谷歌搜索。 从容器中查找d​​ns似乎是一个问题。

traefik日志中的错误:

time="2020-01-30T12:12:12+01:00" level=error msg="Unable to obtain ACME certificate for domains \"traefik.xyz.se\": cannot get ACME client get directory at 'https://acme-v02.api.letsencrypt.org/directory': Get https://acme-v02.api.letsencrypt.org/directory: dial tcp: lookup acme-v02.api.letsencrypt.org on 127.0.0.11:53: read udp 127.0.0.1:54773->127.0.0.11:53: i/o timeout" providerName=cloudflare.acme routerName=traefik-secure@docker rule="Host(`traefik.xyz.se`)"
time="2020-01-30T12:12:32+01:00" level=error msg="Unable to obtain ACME certificate for domains \"hivemq.xyz.se\": cannot get ACME client get directory at 'https://acme-v02.api.letsencrypt.org/directory': Get https://acme-v02.api.letsencrypt.org/directory: dial tcp: lookup acme-v02.api.letsencrypt.org on 127.0.0.11:53: read udp 127.0.0.1:53671->127.0.0.11:53: i/o timeout" rule="Host(`hivemq.xyz.se`)" providerName=cloudflare.acme routerName=hivemq-secure@docker

无法从traefik容器中查找google。不知道这是否按预期工作?

/o/a/traefik> docker exec -it traefik /bin/sh
/ # nslookup google.se
nslookup: can't resolve '(null)': Name does not resolve

nslookup: can't resolve 'google.se': Try again
/ #

Traefik docker-compose.yaml

version: '3'

services:
  traefik:
    image: traefik:v2.1
    container_name: traefik
    restart: unless-stopped
    security_opt:
      - no-new-privileges:true
    networks:
      - proxy
    ports:
      - 80:80
      - 443:443
    environment:
      - CF_API_EMAIL=redacted
      - CF_API_KEY=redacted
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./data/traefik.yml:/traefik.yml:ro
      - ./data/acme.json:/acme.json
      - ./data/config.yml:/config.yml:ro
    labels:
  - "traefik.enable=true"
  - "traefik.http.routers.traefik.entrypoints=http"
  - "traefik.http.routers.traefik.rule=Host(`traefik.xyz.se`)"
  - "traefik.http.middlewares.traefik-auth.basicauth.users=redacted"
  - "traefik.http.middlewares.traefik-https-redirect.redirectscheme.scheme=https"
  - "traefik.http.routers.traefik.middlewares=traefik-https-redirect"
  - "traefik.http.routers.traefik-secure.entrypoints=https"
  - "traefik.http.routers.traefik-secure.rule=Host(`traefik.xyz.se`)"
  - "traefik.http.routers.traefik-secure.middlewares=traefik-auth"
  - "traefik.http.routers.traefik-secure.tls=true"
  - "traefik.http.routers.traefik-secure.tls.certresolver=cloudflare"
  - "traefik.http.routers.traefik-secure.tls.domains[0].main=xyz.se"
  - "traefik.http.routers.traefik-secure.tls.domains[0].sans=*.xyz.se"
  - "traefik.http.routers.traefik-secure.service=api@internal"    
networks:
  proxy:
    external: true

data / traefik.yml:

api:
  dashboard: true
  debug: true

entryPoints:
  http:
    address: ":80"
  https:
    address: ":443"

providers:
  docker:
    endpoint: "unix:///var/run/docker.sock"
    exposedByDefault: false
  file:
    filename: /config.yml

certificatesResolvers:
  cloudflare:
    acme:
      email: redacted
      storage: acme.json
      dnsChallenge:
        provider: cloudflare
        delayBeforeCheck: 0
        resolvers:
          - "1.1.1.1:53"
          - "8.8.8.8:53"

服务示例(hivemq)docker-compose.yml:

version: "3"

services:
  hivemq:
    image: hivemq/hivemq4
    container_name: hivemq
    restart: unless-stopped
    security_opt:
      - no-new-privileges:true
    ports:
      - 1883:1883
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.hivemq.entrypoints=http"
      - "traefik.http.routers.hivemq.rule=Host(`hivemq.xyz.se`)"
      - "traefik.http.routers.hivemq.middlewares=https-redirect@file"
      - "traefik.http.routers.hivemq-secure.middlewares=secured@file"
      - "traefik.http.routers.hivemq-secure.entrypoints=https"
      - "traefik.http.routers.hivemq-secure.rule=Host(`hivemq.xyz.se`)"
      - "traefik.http.routers.hivemq-secure.tls=true"
      - "traefik.http.routers.hivemq-secure.service=hivemq"
      - "traefik.http.services.hivemq.loadbalancer.server.port=8080"
      - "traefik.docker.network=proxy"
    networks:
      - internal
      - proxy

networks:
  proxy:
    external: true
  internal:
    external: false

我也尝试过重新安装docker-ce,没有帮助。

2 个答案:

答案 0 :(得分:1)

我有一个类似的问题,这是由于Docker的错误所致:我所有的容器都失去了与互联网的连接,但是它们已经全部被移除以进行维护,所以我看不到。

在日志中,cannot get ACME client get directory表示Traefik无法连接到“让我们加密” URL。

我通过以下方式解决了此问题:

  • 删除Traefik堆栈
  • 修剪网络,以删除traefik-public
  • 重新启动Docker服务

如果还不够,您可以尝试以下方法:

  • 尝试重新启动Docker引擎,它将重置所有iptables规则(假设您在Linux上使用Docker)
  • 尝试重新启动整个计算机
  • 尝试禁用(临时)计算机的防火墙以验证它可以解决此问题

如此处所述:https://community.containo.us/t/cannot-create-renew-acme-certificate-cannot-get-acme-client-get-directory/2469/2

多年来,我快速浏览了有关连接丢失的Docker错误,似乎一团糟:https://github.com/moby/moby/issues/15172

答案 1 :(得分:0)

不是docker专家,但我遇到了类似的问题,并通过在docker daemon上激活ipv6来解决了这个问题:

% grep ipv6 /etc/docker/daemon.json
    "ipv6": true`

然后您需要重新加载docker daemon

% sudo systemctl reload docker