This guide explains how to keep your main DNS in Porkbun but delegate the
_acme-challenge subdomain to Cloudflare so Traefik can automatically obtain
wildcard and subdomain certificates via Let’s Encrypt.
- Log into Cloudflare.
- Add a new site:
example.com(replace with your domain). - Cloudflare will give you two nameservers, e.g.:
aria.ns.cloudflare.com gabe.ns.cloudflare.com
In your Porkbun DNS settings for example.com, add NS records (Replace the NS records with the ones provided by CloudFlare):
| Host | Type | Value |
|---|---|---|
_acme-challenge |
NS | aria.ns.cloudflare.com. |
_acme-challenge |
NS | gabe.ns.cloudflare.com. |
The trailing dot may be required by Porkbun.
Now, everything under _acme-challenge.example.com will be managed by Cloudflare.
Update Traefik’s static configuration (traefik.yml or traefik.toml):
certificatesResolvers:
cf:
acme:
email: [email protected]
storage: /letsencrypt/acme.json
dnsChallenge:
provider: cloudflare
delayBeforeCheck: 10senvironment:
- CF_DNS_API_TOKEN=your_cloudflare_api_token- The API token should have Zone → DNS:Edit permission for
_acme-challenge.example.com. - Restrict the token to this sub-zone only (least privilege).
- For a wildcard cert:
*.example.com→ TXT record at_acme-challenge.example.com - For a subdomain cert:
foo.example.com→ TXT record at_acme-challenge.foo.example.com
Both records live under the delegated _acme-challenge.example.com zone in Cloudflare,
so Traefik can create them automatically.
Run these to confirm delegation and TXT creation:
# Check NS delegation
dig NS _acme-challenge.example.com +short
# Check TXT after Traefik tries to issue
dig TXT _acme-challenge.example.com +short
dig TXT _acme-challenge.foo.example.com +short- Root domain certs (
example.com) also work — Traefik will create the TXT at_acme-challenge.example.com, which is delegated to Cloudflare. - If you don’t need wildcards, you can skip this setup and just use HTTP-01.
Now Traefik will handle automatic renewal of both wildcard and subdomain certificates using Cloudflare, while you keep your primary DNS in Porkbun.