I originally posted my question on StackOverflow: Traefik self-signed certificated wildcard subdomain in docker-compose - Stack Overflow
I'm looking for a solution to let traefik generate a wildcard certificate for my services. In fact in local development I do have multiple services sharing the same domain and currently I have to accept the certificate for each one.
I have 2 subdomains
api.domain.localhost and I would like a single certificate for both.
Here is a demo docker-compose.yml:
version: '3' services: traefik: image: traefik:2.5 command: - --providers.docker - --entryPoints.http.address=:80 - --entryPoints.http.http.redirections.entryPoint.to=https - --entryPoints.http.http.redirections.entryPoint.scheme=https - --entryPoints.https.address=:443 labels: - traefik.enable=true ports: - "80:80" - "443:443" volumes: - /var/run/docker.sock:/var/run/docker.sock front: image: traefik/whoami labels: - traefik.http.routers.front_router.rule=Host(`front.domain.localhost`) - traefik.http.routers.front_router.entrypoints=https - traefik.http.routers.front_router.tls=true api: image: traefik/whoami labels: - traefik.http.routers.api_router.rule=Host(`api.domain.localhost`) - traefik.http.routers.api_router.entrypoints=https - traefik.http.routers.api_router.tls=true
With this one I should accept 2 certificates (one for each subdomain).
I tried with various combination of
sans as explained in Routers - Traefik without success.
How can I achieve this ?