Search code examples
dockertraefik

I'm trying to configure traefik + docker, but the browser loads the https url forever, do you know why?


I'm trying to configure traefik + docker but I'm having troubles: the browser loads the URL forever. This is my actual configuration:

traefik.toml

debug = false

logLevel = "ERROR"
defaultEntryPoints = ["https","http"]

[entryPoints]

[entryPoints.http]
address = ":80"
[entryPoints.http.redirect]
entryPoint = "https"

# https is the default
[entryPoints.https]
address = ":443"
[entryPoints.https.tls]

[docker]
endpoint = "unix:///var/run/docker.sock"
domain = "cloud.castignoli.it"
watch = true
exposedByDefault = false

[acme]
email = "[email protected]"
storage = "acme.json"
entryPoint = "https"
onHostRule = true
[acme.httpChallenge]
entryPoint = "http"

Then I have the acme.json, actually filled by treafik with the correct values.

I'm trying to activate https for the container foo, the domain is hello.cloud.castignoli.it foo has only this label

traefik.frontend.rule=Host:hello.cloud.castignoli.it

These are traefik's logs

time="2018-10-11T08:04:50Z" level=error msg="Unable to obtain ACME certificate for domains \"reverse-proxy.traefik.\" detected thanks to rule \"Host:reverse-proxy.traefik.\" : unable to generate a certificate for the domains [reverse-proxy.traefik.]: acme: Error 400 - urn:ietf:params:acme:error:malformed - Error creating new order :: DNS name ends in a period"

This is the traefik dashboard traefik's dashboard


Solution

  • The problem is with the domain for the traefik that is trying to generate a certificate for a non-existent domain.

    In docker-compose.yml set labels with your domain or do not use --api. For example:

      image: traefik                                                                                                                                                                                                                                                                  
      command: --api --docker                                                                                                                                                                                                                                                         
      ports:                                                                                                                                                                                                                                                                            
        - "80:80"                                                                                                                                                                                                                                                                       
        - "443:443"                                                                                                                                                                                                                                                                     
        - "8080:8080"                                                                                                                                                                                                                                                                 
      networks:                                                                                                                                                                                                                                                                         
        - web                                                                                                                                                                                                                                                                         
      volumes:                                                                                                                                                                                                                                                                          
        - /var/run/docker.sock:/var/run/docker.sock                                                                                                                                                                                                                                     
        - /opt/traefik/traefik.toml:/traefik.toml                                                                                                                                                                                                                                       
        - /opt/traefik/acme.json:/acme.json                                                                                                                                                                                                                                           
      labels:                                                                                                                                       
        - "traefik.docker.network=web"                                                                                                                                      
        - "traefik.port=8081"                                                                    
        - "traefik.enable=true"                                                                                                                                       
        - "traefik.frontend.rule=Host:your-awesome-host.com"