Search code examples
dockertraefik

docker traefik error key has already been defined


I restarted a server with docker containers and traefik, everthing was fine before that but now I have this

2022/10/24 18:45:08 command traefik error: toml: line 23 (last key "certificatesResolvers.myResolver.acme"): Key 'certificatesResolvers.myResolver.acme.httpChallenge' has already been defined.

Error from docker logs

And the docker container is always restarting

I tried changing "myResolver" by something else but it gives the same error, none of my sites work because of that.

EDIT:

toml file:

[entryPoints]
  [entryPoints.web]
    address = ":80"
    [entryPoints.web.http]
      [entryPoints.web.http.redirections]
        [entryPoints.web.http.redirections.entryPoint]
          to = "websecure"
          scheme = "https"

  [entryPoints.websecure]
    address = ":443"

[api]
dashboard = true

[providers.docker]
  endpoint = "unix:///var/run/docker.sock"

[certificatesResolvers.myResolver.acme]
  email = "myMail@gmail.com"
  storage = "acme.json"
  httpChallenge = true
  [certificatesResolvers.myResolver.acme.httpChallenge]
    entryPoint = "web"

docker-compose :

version: '3.2'
networks:
  myNetwork:
    external: true
services:
  reverse-proxy:
    restart: always
    image: traefik:v2.6
    ports:
      - 80:80
      - 443:443
    volumes:
      - ./traefik.toml:/etc/traefik/traefik.toml
      - /var/run/docker.sock:/var/run/docker.sock
      - ./acme.json:/acme.json
    networks:
      - myNetwork
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.reverse-proxy.rule=Host('dashboard.com')"
      - "traefik.http.routers.reverse-proxy.service=api@internal"
      - "traefik.http.routers.reverse-proxy.entrypoints=websecure"
      - "traefik.http.routers.reverse-proxy.tls=true"
      - "traefik.http.routers.reverse-proxy.tls.certresolver=myResolver"

there is only those 2 files and the acme.json


Solution

  • I solved it! I just found that "httpChallenge=true" line was not an acceptable line, weird thing is that it was working before :/

    old traefik.toml

    [entryPoints]
      [entryPoints.web]
        address = ":80"
        [entryPoints.web.http]
          [entryPoints.web.http.redirections]
            [entryPoints.web.http.redirections.entryPoint]
              to = "websecure"
              scheme = "https"
    
      [entryPoints.websecure]
        address = ":443"
    
    [api]
    dashboard = true
    
    [providers.docker]
      endpoint = "unix:///var/run/docker.sock"
    
    [certificatesResolvers.myResolver.acme]
      email = "myMail@gmail.com"
      storage = "acme.json"
      httpChallenge = true
      [certificatesResolvers.myResolver.acme.httpChallenge]
        entryPoint = "web"
    

    new traefik.toml

    [entryPoints]
      [entryPoints.web]
        address = ":80"
        [entryPoints.web.http]
          [entryPoints.web.http.redirections]
            [entryPoints.web.http.redirections.entryPoint]
              to = "websecure"
              scheme = "https"
    
      [entryPoints.websecure]
        address = ":443"
    
    [api]
    dashboard = true
    
    [providers.docker]
      endpoint = "unix:///var/run/docker.sock"
    
    [certificatesResolvers.myResolver.acme]
      email = "myMail@gmail.com"
      storage = "acme.json"
      [certificatesResolvers.myResolver.acme.httpChallenge]
        entryPoint = "web"
    

    It now works and I have my certificates on my sites.