Wildcard Domains With Coolify and Cloudflare
Tutorial

Wildcard Domains With Coolify and Cloudflare

A wildcard certificate can't be proven the way a normal one is — there's no single page to fetch for a domain that doesn't exist yet. That's why it needs a DNS record instead of an HTTP request, and why Cloudflare's API has to be involved at all.

Published June 26, 202611 min readUpdated Sep 6, 2026

Written by · Full-Stack Agentic AI Software Engineer — AI Agents, Automation & Revenue Systems for GTM/RevOps teams

In brief

Why does a wildcard certificate need Cloudflare's API at all, and what does setting that up in Coolify actually involve?

A normal Let's Encrypt certificate is proven with HTTP-01: the ACME client puts a file at a known path and Let's Encrypt fetches it over HTTP. That only works for domains that already exist and resolve. A wildcard covers every possible subdomain, including ones that don't exist yet, so there's nothing to fetch — the only way to prove ownership is DNS-01, where the ACME client creates a TXT record under _acme-challenge.<domain> and Let's Encrypt reads that instead. That requires API access to the DNS provider, which is why Coolify's Traefik proxy needs a Cloudflare API token (CF_DNS_API_TOKEN) with DNS-edit permission scoped to the specific zone, configured in the server's Proxy settings with the ACME DNS challenge provider set to cloudflare. Once it's issuing a real wildcard, Coolify's own per-server Wildcard Domain setting can hand every new resource a subdomain automatically — which is what makes per-branch preview URLs practical instead of a manual DNS entry per deploy.

  • HTTP-01 validation fetches a file over HTTP at a known path — it can't prove ownership of subdomains that don't exist yet, which is exactly what a wildcard covers
  • DNS-01 validation proves ownership by creating a TXT record under _acme-challenge.<domain>, which works for a wildcard because it doesn't depend on any specific subdomain resolving
  • Coolify configures DNS-01 with Cloudflare through a CF_DNS_API_TOKEN environment variable and a dnschallenge.provider=cloudflare flag on Traefik, set in Servers → Proxy
  • The Cloudflare API token should be scoped to Zone:DNS:Edit on the specific zone, not an account-wide token — least privilege matters more here because the token lives on the server issuing certificates
  • Coolify's server-level Wildcard Domain setting can't itself issue wildcard certificates through the built-in proxy button — actual wildcard TLS needs the DNS-01 challenge configured separately, and the wildcard domain setting is what then puts it to use for automatic per-resource subdomains

Evidence notes

DNS-01 challenge mechanism and Cloudflare configuration

Coolify's own docs describe DNS-01 as Traefik asking the DNS provider to create a temporary TXT record under _acme-challenge.<domain>, configured via Servers → Proxy with CF_DNS_API_TOKEN and --certificatesresolvers.letsencrypt.acme.dnschallenge.provider=cloudflare.

Coolify's built-in proxy can't issue catch-all certificates

Coolify's own domains documentation states the Coolify Proxy won't be able to issue SSL certificates for catch-all domains through its default flow — a genuine wildcard certificate needs the DNS challenge configured separately.

Cloudflare least-privilege API token scoping

Cloudflare's own documentation recommends scoping an API token to the specific zone it needs rather than granting account-wide access, following the principle of least privilege.

Let's Encrypt authorization failure limit

Up to 5 authorization failures per identifier can be incurred by one account every hour, refilling at one per identifier every 12 minutes — relevant when a DNS-01 challenge is misconfigured and retried repeatedly.

A wildcard certificate covers *.yourdomain.com — every subdomain, including the ones that don't exist yet and might never exist. That last part is exactly why it can't be issued the ordinary way. Let's Encrypt's default method for proving domain ownership is fetching a file over HTTP from the domain itself, and there's no file to fetch from a subdomain nobody's created. Proving you control a wildcard needs a completely different mechanism, and getting Coolify to use that mechanism with Cloudflare is a specific, small piece of configuration that most Coolify tutorials skip entirely because most Coolify tutorials only ever need one domain.

Why can't a wildcard certificate use the normal HTTP validation?

HTTP-01 validation works like this: the ACME client puts a specific file at a known path on the domain being validated, and Let's Encrypt's servers fetch that path over plain HTTP to confirm whoever requested the certificate actually controls what's being served there. It's simple, it's why certificate automation for a single domain is nearly invisible, and it fundamentally requires the domain to already resolve to something that can serve that file. app.yourdomain.com can prove itself this way because app.yourdomain.com exists and answers requests. *.yourdomain.com is a promise about every possible subdomain, most of which have never been created and never will be. There's nothing to fetch from a subdomain that doesn't exist, so HTTP-01 simply cannot validate a wildcard — not "is hard to," cannot, structurally. If the hard part of wildcard domains with coolify and Cloudflare for you is organisational rather than technical, the team at XenGrowth is worth reading.

DNS-01 solves this by asking a different question entirely: instead of "can you serve a file from this exact hostname," it asks "can you create a DNS record under this domain's authoritative nameservers." The ACME client creates a TXT record at _acme-challenge.yourdomain.com with a value Let's Encrypt gave it, Let's Encrypt looks that record up, and if it matches, ownership of the whole domain — wildcard included — is proven. That's a DNS operation, not an HTTP one, which is exactly why it needs API access to whatever's hosting the domain's DNS rather than needing the target subdomain to exist at all.


HTTP-01

DNS-01

What gets proven

The exact hostname on the certificate resolves and serves a specific file

Control over the domain's DNS records, at any authoritative-nameserver level

Works for a wildcard certificate

No — there's no single hostname to fetch a file from

Yes — this is the only method that can validate *.domain.com

What it needs access to

Port 80 on the server the domain points to

An API token for the DNS provider, with permission to create and delete records

Typical failure mode

Firewall blocking port 80, or DNS not yet pointed at the server

API token missing DNS-edit permission, or DNS propagation not finished before Let's Encrypt checks

How do you actually turn this on in Coolify?

  1. In Coolify, go to Servers → your server → Proxy, where the default configuration uses HTTP-01 (the http challenge) for Traefik's certificate resolver.

  2. Add CF_DNS_API_TOKEN as an environment variable for the proxy, set to a Cloudflare API token generated specifically for this purpose — not a reused general-purpose token.

  3. Change the certificate resolver's challenge configuration to the DNS challenge, with the provider set to cloudflare — the Traefik flag is --certificatesresolvers.letsencrypt.acme.dnschallenge.provider=cloudflare.

  4. If DNS-01 validation fails intermittently, add a delay before Traefik checks for the TXT record's propagation — DNS writes aren't instant, and checking too early is a common false failure.

  5. Restart the proxy so the new configuration takes effect, then request a certificate for *.yourdomain.com the same way any other domain gets one added in Coolify.

  6. Separately, set the server's Wildcard Domain field (in the server's general settings) to the base domain — this is what makes every new resource on that server get an automatically generated subdomain, rather than needing a manual DNS entry each time.

That last step is worth calling out on its own, because it's easy to conflate with the DNS-01 setup and they're not the same thing. Coolify's server-level Wildcard Domain field controls automatic subdomain assignment for resources — it's a convenience feature, and it exists independent of how the certificate for that wildcard actually gets issued. Coolify's own documentation is explicit that the built-in Coolify Proxy flow won't issue SSL certificates for catch-all domains on its own; the DNS-01 configuration above is what actually makes a real wildcard certificate exist. Without it, the Wildcard Domain setting can assign subdomains, but Coolify has nothing valid to present for HTTPS on any of them. The XenGrowth resource library covers the the operations side of this side of this.

What Cloudflare API token permissions does this actually need?

The least amount that gets the job done, and Cloudflare makes that easy to enforce: create a token scoped to Zone → DNS → Edit, restricted to the one zone this covers, rather than an account-wide token or one of the broader legacy Global API Key credentials. This isn't a theoretical security nicety — this token lives in an environment variable on a server that's reachable from the internet, and the blast radius of it leaking is the difference between "someone can edit DNS for one domain" and "someone can edit DNS, and potentially more, for every zone on the account." Cloudflare's own guidance is explicit about scoping tokens to the specific zone rather than granting broader access, which is exactly the principle at stake here.

  • Create a dedicated token, not a reused one — if it needs rotating later, nothing else breaks

  • Scope it to Zone:DNS:Edit on the specific zone the wildcard covers, not the whole account

  • Store it as CF_DNS_API_TOKEN on the proxy only — it doesn't need to exist anywhere else in the stack

  • Rotate it if it's ever pasted into a shared chat, a public repo, or anywhere outside Coolify's own environment variable storage

Does Cloudflare's orange-cloud proxying interfere with any of this?

Not with the certificate issuance itself — DNS-01 validation happens entirely through Cloudflare's API, checking a TXT record, which has nothing to do with whether traffic to the domain is proxied through Cloudflare's network or resolves directly. This is actually one of DNS-01's practical advantages over HTTP-01 in a Cloudflare setup: HTTP-01 needs port 80 reachable on the origin, which can get tangled with Cloudflare's own SSL/TLS mode settings and proxying; DNS-01 sidesteps that whole path because it never touches the HTTP layer at all. What proxying does affect is what happens after the certificate exists: a subdomain that's proxied (orange cloud on) is served through Cloudflare's edge, gets the benefits described in what Cloudflare's free tier actually does for a self-hosted app, and hides the origin IP from casual lookups; a subdomain left unproxied (grey cloud) resolves straight to the VPS, which is sometimes deliberately what you want for a preview environment where Cloudflare's caching would otherwise get in the way of seeing changes immediately.

Setup choice

What it affects

When to use it

Cloudflare proxy on (orange cloud)

Traffic to that subdomain, and only that — never certificate issuance

Production apps that want the CDN, WAF, and origin-hiding benefits

Cloudflare proxy off (grey cloud)

Same — traffic resolves directly to the VPS

Preview or staging subdomains where you want to see changes without a cache layer in the way

DNS-01 challenge configured

Certificate issuance for the wildcard itself

Required once, regardless of whether any given subdomain ends up proxied or not

What actually goes wrong when the DNS-01 challenge fails?

Almost always one of two things: the API token doesn't actually have permission to write the TXT record it's trying to create, or Traefik checks for that record before Cloudflare's DNS has finished propagating it. The first shows up as an authentication or permission error in the proxy's own logs, immediately, and it's usually a token generated with the wrong scope or the wrong zone selected when it was created. The second is quieter — the challenge times out looking for a record that does exist, just not yet where Traefik happened to check for it — and it's exactly what the propagation delay setting exists to absorb. Neither failure is rare on a first attempt, which is worth knowing going in so it doesn't read as a sign the whole approach is broken. For the AI agents and marketing automation angle, see XenGrowth on governed AI marketing workflows.

  • Token error in the logs: regenerate the token, double-check it's scoped to Zone:DNS:Edit on the correct zone, and confirm it hasn't been pasted with a trailing space or missing character

  • Challenge times out waiting for the TXT record: add or increase the propagation delay before Traefik checks, since Cloudflare's own DNS writes aren't instantaneous

  • Works for the base domain but not the wildcard specifically: confirm the certificate request actually includes *.yourdomain.com, not just yourdomain.com — these are two separate identifiers to Let's Encrypt even on the same certificate

  • Repeated failed attempts start getting rejected outright: that's the authorization-failure rate limit — five per identifier per hour — so fix the underlying cause first rather than immediately retrying

What if Cloudflare only handles DNS and something else handles the app's traffic?

That's actually the common case, and it doesn't change anything about the certificate side. DNS-01 validation only cares whether the API token can create and read a TXT record on the zone — it has no opinion on whether traffic to that domain is proxied through Cloudflare, sent straight to the origin, or routed through something else entirely. As long as Cloudflare is the authoritative DNS provider for the zone (nameservers pointed at Cloudflare, which is the default setup for any domain added to a Cloudflare account), the API token can manage records for it regardless of what's actually serving HTTP or HTTPS traffic for that domain. The two concerns — who answers DNS queries, and who answers HTTP requests — are genuinely separate, and DNS-01 only ever touches the first one.

The one place this distinction does matter is if a domain's nameservers were never actually moved to Cloudflare — a subdomain merely added there while the parent zone lives elsewhere. In that case Cloudflare's API has nothing authoritative to write a TXT record against, and the DNS-01 challenge fails for a reason that has nothing to do with the token or Traefik's configuration at all. Checking that the zone genuinely lives in Cloudflare, before troubleshooting anything else, saves a fair amount of confused debugging the first time this comes up. XenGrowth on building one SEO and GEO content system goes further into AI search, GEO and discovery.

A wildcard certificate isn't proven by anything the wildcard actually serves. It's proven entirely through DNS, which is the one part of this that never has to wait for a subdomain to exist first.

What does this actually unlock once it's working?

Per-branch preview subdomains, mainly — feature-branch.yourdomain.com or pr-42.yourdomain.com getting a real, valid HTTPS URL the moment a deploy exists, with no manual DNS entry and no manual certificate request per branch. Once the wildcard certificate exists and Coolify's Wildcard Domain setting is pointed at the base domain, every new resource can be handed a subdomain automatically as part of the same deploy flow described in the git-push-to-production workflow — the certificate problem that would otherwise block this entirely is already solved before the first preview branch is ever pushed.

That's the actual payoff, and it's worth being clear it's not a small one: a genuinely unlimited number of working, HTTPS-valid preview environments, for the cost of one wildcard certificate and one API token scoped correctly. Compared to running a separate DNS-01 setup or paying for a platform that bundles this in, the entire mechanism here is free — the only thing spent is the fifteen minutes it takes to configure the DNS challenge once.

Further reading from XenGrowth

Where this work meets go-to-market

For the marketing and revenue operations view of wildcard domains with coolify and Cloudflare, see XenGrowth's growth operations team.

Why won't the wildcard certificate issue?

Four questions on wildcard DNS and the certificate step that catches people out. The DNS half is easy; the validation half is where the afternoon goes.

1 / 4
Why can't a wildcard certificate use the HTTP-01 challenge?

Apply this article

How to turn insights into execution

A practical sequence for teams turning concepts into production outcomes.

CoolifyCloudflareWildcard SSLDNS-01TraefikLet's EncryptSelf-Hostingtutorials

Audit your current state

Map the bottlenecks and constraints connected to the article’s core problem.

Choose one bounded change

Test the most useful recommendation on one workflow before widening the scope.

Measure what changed

Keep the parts that improve the work, document what failed, and make the next decision from evidence.

Next step

Need help applying this in your stack?

I can translate these patterns into a concrete implementation plan for your team.

Discuss implementationBack to blog

Replies usually within 24 hours.

Next Steps

Continue reading

How to Self-Host Next.js With Coolify: A Complete 2026 Walkthrough

Every Coolify tutorial stops at "push to deploy." This one covers the parts that actually break a real app: standalone output, a build that OOMs on a small box, env vars baked in at the wrong time, and a health check that would have caught all of it.

Navigate

How I Restore an Entire Server From Backup (And How Long It Takes)

The order matters more than people expect, and the answer to "how long will this take" isn't a number I can hand you — it's dominated by your database size, your download bandwidth, and one DNS setting most people only think to change after they needed to.

Navigate

How to Host Unlimited Domains on One VPS With Free SSL

"Unlimited domains, one server" sounds like a sales pitch, but it's a genuinely accurate description of what SNI-based virtual hosting and Let's Encrypt automation do together. The real ceiling isn't domain count. It's RAM.

Navigate

The Docker Concepts You Need Before Coolify Hides Them From You

Coolify's whole pitch is that you shouldn't have to think about Docker, and most days that's true. The days it isn't are the days a container is 'running' but unhealthy, a redeploy quietly ate a volume, or an env var vanished — and the dashboard doesn't explain any of it.

Navigate

How to Back Up and Restore a Coolify Server Properly

Coolify's built-in backup covers less than most people assume, and a filesystem copy of a live Postgres data directory is not a valid database backup no matter how confident it looks in a file listing. Here's what actually has to be backed up, and a restore you've actually tried before you need it.

Navigate

Where console.log Actually Goes When You Self-Host Next.js

On Vercel, a console.log just shows up in a dashboard somewhere. Self-hosted, it goes through a chain most people never trace end to end — and the two most common questions I get are why a log doesn't show up at all, and why the disk filled with logs nobody remembers writing.

Navigate

My Complete Self-Hosted Stack for SaaS in 2026

Contabo, Coolify, Docker, Cloudflare, Postgres, R2, Resend, Uptime Kuma, Turborepo and Docker Hub. Here's every piece of the stack I actually run, what each one replaced, and why I picked it over the alternatives.

Navigate

Preview Environments Without Vercel: Branch Deploys on Your Own VPS

A preview URL per branch is the one Vercel feature people miss most after leaving. It's buildable on your own server, and it's genuinely harder than Vercel makes it look — mostly because of the database, which nobody's marketing page mentions.

Navigate

The Contabo + Coolify + Cloudflare Stack That Replaced My Vercel Bill

Three pieces, not thirty. Here's exactly what each one does, why that specific combination and not one of the dozen others I considered, and which parts of Vercel each one is actually standing in for.

Navigate

How I Back Up PostgreSQL to S3-Compatible Storage on a Schedule

pg_dump, pg_basebackup and WAL archiving aren't three ways to do the same thing — they answer three different questions about how much data you're willing to lose. Here's which one to run, from a container that has no business having shell access to your host, pushed to storage that makes restoring free instead of expensive.

Navigate