I can't seem to get a basic example of traefik and whoami running with self-signed certs (and ca) with docker compose. I suspect the issue is something to do with TLS termination? Importantly, I am not using labels, I am using traefik.yml and dynamic.yml configuration.
Currently I get when visiting https://localhost/whoami:
502 Bad Gateway error="remote error: tls: bad certificate"
I have two containers running: Traefik, and whoami.
I used mkcert to generate the certs for whoami. I'm mounting the certs in /certs
for both containers and running the whoami container with:
command: --cert /certs/cert.pem --key /certs/key.pem --cacert /certs/rootCA.pem --port 443
I would like traefik to accept a https request, and not forward a http call to whoami (that's easy to get working) but instead talk only over https with it, so all containers are running on https for localhost. Therefore, I understand that I need to tell traefik two things:
- Here is the CA that you can use
- Here is the cert and key
Still, here is my configuration:
traefik.yml
log:
level: DEBUG
entryPoints:
http:
address: ':80'
https:
address: ':443'
providers:
docker:
endpoint: "unix:///var/run/docker.sock"
exposedByDefault: false
network: app_network
# Dynamic configuration
file:
filename: /etc/traefik/dynamic.yml
watch: true
dynamic.yml
tls:
certificates:
- certFile: /certs/cert.pem
keyFile: /certs/key.pem
stores:
default:
defaultCertificate:
certFile: /certs/cert.pem
keyFile: /certs/key.pem
http:
serversTransports:
whoami-transport:
rootCAs:
- /certs/rootCA.pem
certificates:
- certFile: /certs/cert.pem
keyFile: /certs/key.pem
routers:
whoami:
rule: Host(`localhost`) && PathPrefix(`/whoami`)
service: whoami
entryPoints:
- https
tls: {}
services:
whoami:
loadBalancer:
serversTransport: whoami-transport
servers:
- url: https://whoami:443
What am I doing wrong? From what I can see:
- traefik is being told that for whoami-transport use the rootCA provided
- the whoami-transport is specified for the whoami service loadbalancer
I have read that I need to change to a tcp setup instead and use passthrough. I haven't tried this yet. AFAIK this is just a https thing, no tcp stuff. whoami is running on 443...