Skip to Content
DocumentationGuidesSet up a DNS challenge with Cloudflare

Set up a DNS challenge with Cloudflare

By default, Companion Hub’s Traefik obtains TLS certificates with an HTTP challenge. That path needs your machine reachable from the internet on port 80. A DNS challenge with Cloudflare lets Traefik request trusted certificates from Let’s Encrypt without opening anything to the internet.

You can’t complete this setup in the current release. A DNS challenge needs two changes that Hub doesn’t keep: a Cloudflare API token passed to the traefik container, and a dnsChallenge resolver in traefik.yml. Hub rewrites state/traefik/config/traefik.yml every time the Hub container starts, the Persist Traefik config setting doesn’t stop that, and a user-config/hub-compose.yml override isn’t applied when you start the stack with cihub up. See Customize compose and Traefik.

How it works

Instead of Let’s Encrypt calling in to your machine over HTTP, Traefik proves ownership by writing a challenge record into your Cloudflare zone with an API token. Nothing in the exchange needs your Hub reachable from the internet.

HTTP challenge (default)DNS challenge
Port 80 reachable from the internetRequired–
Domain managed in Cloudflare–✓
Cloudflare API token passed to Traefik–✓
Resolver in traefik.ymlhttpChallenge, entryPoint: webdnsChallenge, provider: cloudflare
Supported by Hub todayYes, the defaultNo
What each challenge type needs from your setup.

The default resolver in <ROOT_FOLDER_HOST>/state/traefik/config/traefik.yml is named myresolver, and Traefik stores its certificates in /etc/traefik/acme.json inside the traefik container, which Hub bind-mounts from <ROOT_FOLDER_HOST>/state/traefik/acme_storage.json. Because scripts/init-traefik.ts regenerates state/traefik/config/traefik.yml from its built-in template every time ci-hub starts (ignoring persistTraefikConfig in state/settings.json), any manual dnsChallenge edits to traefik.yml are overwritten on the next restart.

What to use instead

Pick the option that matches who needs to reach your apps:

  • Trusted HTTPS on the public internet — expose the app through the managed Cloudflare Gateway by setting its Exposure mode to Public Web. Unlike a Let’s Encrypt DNS-01 challenge (where Traefik holds a Cloudflare API token and provisions local ACME certificates), the Cloudflare Gateway runs an outbound cloudflared tunnel (10.128.0.3 on ci-hub_edge) to Cloudflare’s edge, which terminates public TLS automatically with no inbound ports and no local ACME certificate management.
  • Trusted HTTPS for your own devices — use Tailscale (Private VPN exposure mode). Enable HTTPS certificates and MagicDNS for your tailnet in the Tailscale admin console so tailscaled provisions certificates for <hub-name>.<tailnet>.ts.net.
  • HTTPS on your LAN only — supply a local certificate under state/traefik/tls/ and trust it on your devices. See Local SSL certificate.
  • Your own domain — add it as a custom domain in your CI Account. Cloudflare for SaaS issues and renews the certificate for your custom hostname at the edge and forwards traffic down your Hub’s existing tunnel. Forwarding ports 80 and 443 to the Hub for a Let’s Encrypt HTTP-01 or DNS-01 certificate is no longer supported on production Hubs; see Expose your apps.
Last updated on