Error in starting traefik with https

Hi,
I had a working dev application with http only of traefik and a microservice running in docker-compose. Now I am changing it to https. I use mkcert to generate a couple of mock certficates for dev.localhost.

Docker-compose

version: '3'

services:
  traefik:
    image: traefik:v2.0
    command: 
      - --entryPoints.web.address=:80
      - --entryPoints.web-secure.address=:443
      - --providers.docker=true
      - --providers.docker.exposedByDefault=false
      - --providers.docker.tls.cert=/etc/certs/dev.localhost+4.pem
      - --providers.docker.tls.key=/etc/certs/dev.localhost+4-key.pem  
      - --accesslog=true 
      - --log.level=DEBUG
    ports:
      - "80:80"
      - "443:443"
      - "8080:8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock    
      - ./certs:/etc/certs
    labels:
      - "traefik.enable: true"
      - "traefik.http.routers.api.entrypoints: web"
      - "traefik.http.routers.api.service: api@internal"

  test-api:
    build: ./node/test-api
    ports:
      - 8100
    labels:
      - "traefik.enable=true"    
      - "traefik.http.routers.test-api.rule=Host(`dev.localhost`) && PathPrefix(`/api/test`)"
      - "traefik.http.routers.test-api.entrypoints: web-secure"

On building the compose, I get these errors:

traefik_1       | time="2019-11-26T00:15:48Z" level=debug msg="FIXME: Got an status-code for which error does not match any expected type!!!: -1" module=api status_code=-1
traefik_1       | time="2019-11-26T00:15:48Z" level=error msg="Failed to retrieve information of the docker client and server host: error during connect: Get https://%2Fvar%2Frun%2Fdocker.sock/v1.24/version: http: server gave HTTP response to HTTPS client" providerName=docker
traefik_1       | time="2019-11-26T00:15:48Z" level=error msg="Provider connection error error during connect: Get https://%2Fvar%2Frun%2Fdocker.sock/v1.24/version: http: server gave HTTP response to HTTPS client, retrying in 1.080381816s" providerName=docker

I am looking for help in correcting the config.

Thanks!

Hello,

the error come from Docker it-self https://github.com/docker/engine/blob/master/errdefs/http_helpers.go#L66

      - --providers.docker.tls.cert=/etc/certs/dev.localhost+4.pem
      - --providers.docker.tls.key=/etc/certs/dev.localhost+4-key.pem  

The certificate define by providers.docker.tls is for the connection to Docker, not for your services.

If you want to use certificates for your services, you have to define them into the dedicated tls section in the dynamic configuration.

https://docs.traefik.io/v2.0/https/tls/

Having similar issue. I have gone through the doc but it seems confusing. Any help would much appreciated.

This link has been helpful to me for https. As Idez mentioned, I still have to explore providers.docker.tls