Search code examples
docker-composeyamltraefik

Docker-compose traefik Namecheap dns not working


I have the following setup:

docker-compose.yml:

version: '3'

services:
  traefik:
    image: traefik:latest
    container_name: traefik
    restart: unless-stopped
    security_opt:
      - no-new-privileges:true
    networks:
      - proxy
    ports:
      - 80:80
      - 443:443
    environment:
      - NAMECHEAP_API_USER=<removedforsecurity>
      - NAMECHEAP_API_KEY=<removedforsecurity>
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - /home/pi/traefik/data/traefik.yml:/traefik.yml:ro
      - /home/pi/traefik/data/acme.json:/acme.json
      - /home/pi/traefik/data/config.yml:/config.yml:ro
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.traefik.entrypoints=http"
      - "traefik.http.routers.traefik.rule=Host(`traefik-dashboard.local.haywirehax.com`)"
      - "traefik.http.middlewares.traefik-auth.basicauth.users=<removedforsecurity>"
      - "traefik.http.middlewares.traefik-https-redirect.redirectscheme.scheme=https"
      - "traefik.http.middlewares.sslheader.headers.customrequestheaders.X-Forwarded-Proto=https"
      - "traefik.http.routers.traefik.middlewares=traefik-https-redirect"
      - "traefik.http.routers.traefik-secure.entrypoints=https"
      - "traefik.http.routers.traefik-secure.rule=Host(`traefik-dashboard.local.haywirehax.com`)"
      - "traefik.http.routers.traefik-secure.middlewares=traefik-auth"
      - "traefik.http.routers.traefik-secure.tls=true"
      - "traefik.http.routers.traefik-secure.tls.certresolver=namecheap"
      - "traefik.http.routers.traefik-secure.tls.domains[0].main=local.haywirehax.com"
      - "traefik.http.routers.traefik-secure.tls.domains[0].sans=*.local.haywirehax.com"
      - "traefik.http.routers.traefik-secure.service=api@internal"

networks:
  proxy:
    external: true

and traefik.yml:

api:
  dashboard: true
  debug: true
entryPoints:
  http:
    address: ":80"
  https:
    address: ":443"
serversTransport:
  insecureSkipVerify: true
providers:
  docker:
    endpoint: "unix:///var/run/docker.sock"
    exposedByDefault: false
  file:
    filename: /config.yml
certificatesResolvers:
  namecheap:
    acme:
      email: <myemail>
      storage: acme.json
      dnsChallenge:
        provider: namecheap
        resolvers:
          - "1.1.1.1:53"
          - "1.0.0.1:53"

however, when I go to the dashboard, I don't get a let's encrypt cert. instead I get the default traefik one. My guess is that this is due to the following part that is incorrect, but I can't find anywhere where to do it correctly for namecheap.

certificatesResolvers:
  namecheap:
    acme:
      email: <myemail>
      storage: acme.json
      dnsChallenge:
        provider: namecheap
        resolvers:
          - "1.1.1.1:53"
          - "1.0.0.1:53"

Solution

  • I changed the resolvers to my internal DNS server and now it works, my bad.