I want to set up HTTPS to work using custom certificate (.key and .cert). But when I access the website at https://example.com:9000, I can see in the logs that there was TLS handshake error.
docker-compose-traefik.yml
version: "3.7"
services:
traefik:
image: "traefik:v2.0"
networks:
- traefik-net
ports:
- "9000:9000"
- "5000:5000"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "./config/:/etc/traefik/"
- "./cert/:/cert/"
deploy:
replicas: 1
labels:
- "traefik.enable=true"
- "traefik.http.routers.traefik.rule=Host(`example.com`)"
- "traefik.http.routers.traefik.entrypoints=traefik"
- "traefik.http.routers.traefik.tls=true"
- "traefik.http.routers.traefik.service=api@internal"
- "traefik.http.services.traefik.loadbalancer.server.port=8080"
networks:
traefik-net:
external: true
name: traefik-net
config/traefik.yml
log:
level: DEBUG
api:
dashboard: true
insecure: true
providers:
file:
directory: "/etc/traefik"
watch: true
docker:
swarmMode: true
exposedByDefault: false
entrypoints:
traefik:
address: ":9000"
web:
address: ":5000"
config/dynamic_conf.yml
tls:
stores:
default:
defaultCertificate:
certFile: /cert/example.com.cert
keyFile: /cert/example.com.key
certificates:
- certFile: /cert/example.com.cert
keyFile: /cert/example.com.key
stores:
- default
The directory cert contains two files. They are self-signed.
- example.com.cert
- example.com.key.
Debug output
level=debug msg="Adding certificate for domain(s) example.com"
level=debug msg="http: TLS handshake error from 10.255.0.2:53759: remote error: tls: unknown certificate"
What am I doing wrong?