Hi folks, I've been working on getting traefik v2 stood up. In doing so, I'm trying to configure traefik to automatically resolve certificates for my domain. I have been able to successfully resolve a wildcard certificate for my primary domain, I but have not been able to get traefik to resolve a wildcard for a subdomain. Below are the logs providing the error.
time="2024-02-09T22:36:31Z" level=debug msg="Building ACME client..." providerName=cloudflare.acme
time="2024-02-09T22:36:31Z" level=debug msg="https://acme-v02.api.letsencrypt.org/directory" providerName=cloudflare.acme
time="2024-02-09T22:36:31Z" level=debug msg="Using DNS Challenge provider: cloudflare" providerName=cloudflare.acme
time="2024-02-09T22:36:31Z" level=debug msg="legolog: [INFO] [local.michaelcook.dev, *.local.michaeldook.dev] acme: Obtaining bundled SAN certificate"
time="2024-02-09T22:36:32Z" level=debug msg="legolog: [INFO] [*.local.michaeldook.dev] AuthURL: https://acme-v02.api.letsencrypt.org/acme/authz-v3/313211891847"
time="2024-02-09T22:36:32Z" level=debug msg="legolog: [INFO] [local.michaelcook.dev] AuthURL: https://acme-v02.api.letsencrypt.org/acme/authz-v3/313476094357"
time="2024-02-09T22:36:32Z" level=debug msg="legolog: [INFO] [local.michaelcook.dev] acme: authorization already valid; skipping challenge"
time="2024-02-09T22:36:32Z" level=debug msg="legolog: [INFO] [*.local.michaeldook.dev] acme: use dns-01 solver"
time="2024-02-09T22:36:32Z" level=debug msg="legolog: [INFO] [*.local.michaeldook.dev] acme: Preparing to solve DNS-01"
time="2024-02-09T22:36:33Z" level=debug msg="legolog: [INFO] [*.local.michaeldook.dev] acme: Cleaning DNS-01 challenge"
time="2024-02-09T22:36:33Z" level=debug msg="legolog: [WARN] [*.local.michaeldook.dev] acme: cleaning up failed: cloudflare: failed to find zone dev.: zone could not be found "
time="2024-02-09T22:36:33Z" level=debug msg="legolog: [INFO] Skipping deactivating of valid auth: https://acme-v02.api.letsencrypt.org/acme/authz-v3/313211891847"
time="2024-02-09T22:36:33Z" level=debug msg="legolog: [INFO] Deactivating auth: https://acme-v02.api.letsencrypt.org/acme/authz-v3/313476094357"
time="2024-02-09T22:36:33Z" level=error msg="Unable to obtain ACME certificate for domains \"local.michaelcook.dev,*.local.michaeldook.dev\"" providerName=cloudflare.acme error="unable to generate a certificate for the domains [*.local.michaeldook.dev]: error: one or more domains had a problem:\n[*.local.michaeldook.dev] [*.local.michaeldook.dev] acme: error presenting token: cloudflare: failed to find zone dev.: zone could not be found\n" routerName=traefik-secure@docker rule="Host(`traefik.local.michaelcook.dev`)" ACME CA="https://acme-v02.api.letsencrypt.org/directory"
In trying to debug, I decided to try resolving the same wildcard certificate using the lego acme client directly and that was successful! Below are the lego logs including the command I executed
lego --dns cloudflare --domains "local.michaelcook.dev,*.local.michaelcook.dev" --email mcook4728@gmail.com --dns.resolvers="1.1.1.1:53,1.0.0.1:53" run
2024/02/09 23:55:13 [INFO] [local.michaelcook.dev, *.local.michaelcook.dev] acme: Obtaining bundled SAN certificate
2024/02/09 23:55:14 [INFO] [*.local.michaelcook.dev] AuthURL: https://acme-v02.api.letsencrypt.org/acme/authz-v3/313496906427
2024/02/09 23:55:14 [INFO] [local.michaelcook.dev] AuthURL: https://acme-v02.api.letsencrypt.org/acme/authz-v3/313496906437
2024/02/09 23:55:14 [INFO] [*.local.michaelcook.dev] acme: use dns-01 solver
2024/02/09 23:55:14 [INFO] [local.michaelcook.dev] acme: Could not find solver for: tls-alpn-01
2024/02/09 23:55:14 [INFO] [local.michaelcook.dev] acme: Could not find solver for: http-01
2024/02/09 23:55:14 [INFO] [local.michaelcook.dev] acme: use dns-01 solver
2024/02/09 23:55:14 [INFO] [*.local.michaelcook.dev] acme: Preparing to solve DNS-01
2024/02/09 23:55:14 [INFO] cloudflare: new record for local.michaelcook.dev, ID ff3b4c973c1c8ab45344a8582bf97832
2024/02/09 23:55:14 [INFO] [local.michaelcook.dev] acme: Preparing to solve DNS-01
2024/02/09 23:55:14 [INFO] cloudflare: new record for local.michaelcook.dev, ID db6eb0d570ddf96b6d3a485f77209a99
2024/02/09 23:55:14 [INFO] [*.local.michaelcook.dev] acme: Trying to solve DNS-01
2024/02/09 23:55:14 [INFO] [*.local.michaelcook.dev] acme: Checking DNS record propagation using [1.1.1.1:53 1.0.0.1:53]
2024/02/09 23:55:16 [INFO] Wait for propagation [timeout: 2m0s, interval: 2s]
2024/02/09 23:55:21 [INFO] [*.local.michaelcook.dev] The server validated our request
2024/02/09 23:55:21 [INFO] [local.michaelcook.dev] acme: Trying to solve DNS-01
2024/02/09 23:55:21 [INFO] [local.michaelcook.dev] acme: Checking DNS record propagation using [1.1.1.1:53 1.0.0.1:53]
2024/02/09 23:55:23 [INFO] Wait for propagation [timeout: 2m0s, interval: 2s]
2024/02/09 23:55:23 [INFO] [local.michaelcook.dev] acme: Waiting for DNS record propagation.
2024/02/09 23:55:25 [INFO] [local.michaelcook.dev] acme: Waiting for DNS record propagation.
2024/02/09 23:55:27 [INFO] [local.michaelcook.dev] acme: Waiting for DNS record propagation.
2024/02/09 23:55:29 [INFO] [local.michaelcook.dev] acme: Waiting for DNS record propagation.
2024/02/09 23:55:31 [INFO] [local.michaelcook.dev] acme: Waiting for DNS record propagation.
2024/02/09 23:55:33 [INFO] [local.michaelcook.dev] acme: Waiting for DNS record propagation.
2024/02/09 23:55:41 [INFO] [local.michaelcook.dev] The server validated our request
2024/02/09 23:55:41 [INFO] [*.local.michaelcook.dev] acme: Cleaning DNS-01 challenge
2024/02/09 23:55:41 [INFO] [local.michaelcook.dev] acme: Cleaning DNS-01 challenge
2024/02/09 23:55:42 [INFO] [local.michaelcook.dev, *.local.michaelcook.dev] acme: Validations succeeded; requesting certificates
2024/02/09 23:55:43 [INFO] [local.michaelcook.dev] Server responded with a certificate.
Ignore that the lego logs contain logs for resolving the cert for primary domain.
My treafik config and docker compose can be found here.
I've included a screenshot of my cloudflare DNS configuration:
I've tried a lot of things, but the major contention point is obviously that lego works directly but it doesn't work through traefik. The fact that I'm able to resolve certificates for the primary domain via traefik also asserts that my cloudflare API token is correct (and yes, it has access to all zones).
Unfortunately, traefik/lego just don't have enough logging for me to know exactly where there's a difference. I would really appreciate if someone can point me in the right direction.