Hi team ,
I am using the common traefik.yaml file for multiple environments. In some environments, I am using Letsencrypt and some user-defined certificates. with two resolvers. Can you tell me if the below configurations are correct? I am facing an issue; it is taking the Traefik default certificate. Could you please help with troubleshooting the problem?
I have the below configuration files.
docker-compose.yaml
version: "3.3"
services:
traefik:
image: "traefik:v3.0.0-rc5"
container_name: "traefik"
networks:
- qa
command:
- "--log.level=DEBUG"
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--providers.docker.network=qa"
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
- "--certificatesresolvers.myresolver.acme.tlschallenge=true"
- "--certificatesresolvers.myresolver.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory"
- "--certificatesresolvers.myresolver.acme.email=${EMAIL}"
- "--certificatesresolvers.myresolver.acme.dnschallenge=true"
- "--certificatesresolvers.myresolver.acme.dnsChallenge.provider=godaddy"
- "--certificatesresolvers.myresolver.acme.dnsChallenge.delayBeforeCheck=0"
- "--certificatesresolvers.myresolver.acme.storage=/home/ec2-user/traefik/letsencrypt/acme.json"
- "traefik.enable=true"
- "traefik.http.routers.traefik.rule=Host(`traefik.qa.com`)"
- "traefik.http.routers.traefik.entrypoints=websecure"
- "traefik.http.routers.traefik.tls.certresolver=myresolver"
- "traefik.http.routers.traefik.tls.certresolver=selfsigned"
env_file:
- .provider.env
ports:
- "80:80"
- "443:443"
- "8080:8080"
volumes:
- "./letsencrypt:/letsencrypt"
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "/home/ec2-user/traefik/traefik.yml:/etc/traefik/traefik.yml"
- "/home/ec2-user/traefik/certs:/certs"
labels:
- "traefik.enable=true"
- "traefik.http.routers.traefik.rule=Host(`traefik.gtp.internal`)" # change hostname!
- "traefik.http.routers.traefik.service=api@internal"
- "traefik.http.routers.traefik.tls.certresolver=selfsigned"
- "traefik.http.routers.traefik.entrypoints=web,websecure"
- "traefik.http.routers.traefik.tls.certresolver=myresolver"
- "traefik.http.services.traefik.loadbalancer.server.port=8080"
demo:
image: traefik/whoami
labels:
- "traefik.enable=true"
- "traefik.http.routers.demo.rule=Host(`demo.gtp.internal`)"
- "traefik.http.routers.demo.entrypoints=websecure"
- "traefik.http.routers.demo.tls=true"
- "traefik.http.routers.demo.tls.certresolver=selfsigned"
networks:
- qa
networks:
qa:
external: true
.provider.env
GODADDY_API_KEY=
GODADDY_API_SECRET=
traefik.yml
# Global configuration
global:
checkNewVersion: true
sendAnonymousUsage: false
# Entry points
entryPoints:
web:
address: ":80"
websecure:
address: ":443"
# Logging configuration
log:
level: DEBUG
# Access logs
accessLog:
format: common
# API configuration
api:
insecure: true
dashboard: true
debug: true
# Providers configuration
providers:
docker:
endpoint: "unix:///var/run/docker.sock"
exposedByDefault: false
# SSL certificate resolver configuration
certificatesResolvers:
selfsigned:
acme:
email: "${EMAIL}"
storage: "/acme.json"
httpChallenge:
entryPoint: websecure
cloudflare:
acme:
caServer: https://acme-staging-v02.api.letsencrypt.org/directory
email: ${EMAIL}
storage: /etc/traefik/acme.json # chmod 600 this file on the host system
tlsChallenge: {}
dnschallenge:
provider: godaddy
resolvers:
- "1.1.1.1:53"
- "8.8.8.8:53"