Skip to content

DNS and Cloudflare

This page explains the hostname model of a Docker install with TLS and exactly which DNS records and Cloudflare settings it needs. The installer verifies all of this before it starts the stack. See One-click install for the install flow and Installer options for the full flag reference.

An install uses a few distinct names.

Name Installer input Default Purpose
Base domain OPENFLARE_BASE_DOMAIN (required) none Root domain you own. Defaults the other names.
Worker base domain OPENFLARE_WORKER_BASE_DOMAIN the base domain Zone under which every worker gets a hostname (<name>.<worker-base>).
Console host OPENFLARE_CONSOLE_HOST console.<base> Where you open the web console.
API host OPENFLARE_API_HOST none (optional) Public host for the internal plane API used by remote cells. Only needed if you run remote cells. --no-api-host clears it.
Webhook host OPENFLARE_GITHUB_WEBHOOK_HOST hooks.<base> when git push deploy is enabled Receives GitHub webhooks.

A worker hostname is exactly one label below the worker base domain. With worker base domain example.com, demo.example.com is valid, while demo.apps.example.com is not. Hostnames are globally unique; creating a duplicate returns HTTP 409.

A wildcard record *.example.com matches one label only. It does not match example.com itself (the apex) or deeper names such as a.b.example.com. The apex is not routed to workers and is not in the wildcard certificate.

Some labels can never be used as worker hostnames, so they cannot collide with infrastructure names. The default list is:

console, api, www, mail, smtp, imap, pop, auth, admin, status, traefik, dashboard, hooks

Override it with --reserved-worker-labels (installer persists it as PLANE_RESERVED_WORKER_LABELS). Each label must match ^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$, no whitespace is allowed, and duplicates are removed. The control plane rejects reserved labels when a worker or hostname is created. The edge also excludes <label>.<worker-base> from the tenant route.

If your console, API or webhook host is a single label directly under the worker base domain, the installer automatically adds that label to the reserved list. If it is multi-level under the worker base domain (for example console.admin.example.com with worker base example.com), the installer fails with E_HOST_CONFLICT. Pick a single-label host, or use a different worker base domain.

Every host you give the installer is normalized and validated:

  • Lowercase, no trailing dot, no scheme, path, port or whitespace.
  • No empty labels, no underscore, no *.
  • Each label 1 to 63 characters, no leading or trailing hyphen; total length at most 253.
  • Non-ASCII names are converted to punycode.
  • IP addresses are rejected.

Additional rules:

  • The console host must be a fully qualified name (not localhost) and must not equal the base domain or worker base domain.
  • The API host must differ from the console host and must not be an apex.
  • The webhook host must differ from the console and API hosts.

By default the worker base domain equals the base domain, so one Cloudflare zone covers everything. You can split workers into their own zone, for example base example.com and worker base example-apps.com.

When the zones differ, the installer needs access to both, and each zone gets its own wildcard certificate (see TLS and certificates). If the console or API host lies outside the worker base domain, you must create its exact A record yourself; the installer never creates it.

The minimum is a single record in the worker base domain zone:

Type Name Content Proxy status
A * your server’s public IPv4 DNS only or Proxied

That one wildcard covers the console host, the API host and the webhook host as long as they sit under the worker base domain. Exact A records for the console or API host are optional in that case. If you do create one, it must be a single A record that equals the server’s public IP.

Rules the installer enforces:

  • Exactly one wildcard A record. Several A records on the wildcard fail the check.
  • No AAAA record on the wildcard or on an exact console/API host. The installer fails with E_IPV6_UNSUPPORTED (“remove the AAAA record and re-run”).
  • No CNAME at the wildcard or exact hosts. This fails with E_CLOUDFLARE_DNS.
  • If you have CAA records, they must authorize letsencrypt.org (or the CA you configured), otherwise the check fails with E_CLOUDFLARE_CAA.

The installer detects the address by asking api.ipify.org, ipv4.icanhazip.com and ifconfig.me, and needs at least two agreeing answers. It then requires the address to be assigned to a local interface. Hosts behind NAT, or with split-horizon addressing, are rejected unless you set the address explicitly with --public-ipv4 (or OPENFLARE_PUBLIC_IPV4). The address must be globally routable; private, CGNAT, link-local, documentation and reserved ranges fail with E_IPV4.

Set the zone’s SSL/TLS encryption mode to Full (strict) (Cloudflare dashboard → SSL/TLS → Overview) before you install, whatever mode you plan to run. Do this even if every record is DNS only.

  • It costs nothing in DNS-only mode. Grey-cloud records never pass through Cloudflare, so the setting has no effect on them.
  • It is a one-time, zone-wide switch. Once set, you can turn a record to Proxied at any later time without hitting the redirect loop that Flexible or Full (non-strict) cause against an origin that serves HTTPS.
  • It keeps switching modes a single step. Without it, moving to proxied means first going to Cloudflare to change another setting, then coming back.

Both modes run fine under Full (strict); only proxied mode depends on it. The installer enforces it in every mode: if the zone is not on Full (strict) it stops with E_CLOUDFLARE_SSL before changing anything. Universal SSL, by contrast, is only checked when a zone has proxied records.

Each record can be DNS only (grey cloud) or Proxied (orange cloud). The installer works out the edge mode from your records: dns-only (no proxied target), proxied (all proxied) or mixed.

DNS only Proxied
Traffic path Client connects directly to your server Client connects to Cloudflare, which connects to your server
Public resolution must be exactly your public IPv4, no CNAME inside Cloudflare’s edge IPv4 ranges, and not your origin IP
Client IP at the edge Traefik does not trust forwarded headers Traefik trusts X-Forwarded-For only from Cloudflare’s ranges
Extra requirements none Full (strict) SSL, active Universal SSL, firewall open to Cloudflare

The installer checks all of these and refuses to continue otherwise. Items 1 and 3 are the same prerequisites as above; setting Full (strict) early means they already hold:

  1. The zone uses a full setup (not a partial or CNAME setup): E_CLOUDFLARE_ZONE.
  2. Universal SSL is enabled and has an active certificate pack: E_CLOUDFLARE_SSL.
  3. The zone SSL/TLS encryption mode is Full (strict) (strict). Flexible, Off and Full (non-strict) are rejected.
  4. Cloudflare’s IPv4 ranges can be fetched (E_CLOUDFLARE_IP_RANGES). They are written into the Traefik static config as trusted proxy addresses.
  5. Your origin firewall allows Cloudflare’s ranges on ports 80 and 443.

To check that your origin presents the expected certificate directly, bypassing Cloudflare:

Terminal window
openssl s_client -connect <origin-ip>:443 -servername console.example.com

The installer needs two Cloudflare API tokens, and the same tokens are used by Traefik for DNS-01 renewals.

Token Required permission Used for
Zone token (OPENFLARE_CLOUDFLARE_ZONE_API_TOKEN) Zone Read Finding the zone, and reading SSL settings
DNS token (OPENFLARE_CLOUDFLARE_DNS_API_TOKEN) DNS Edit (shown as “DNS Write” in token policies), scoped to the target zone Reading and writing records, and ACME DNS-01 TXT records

Recommended layout: a token with Zone Read and a second token with DNS Edit restricted to the zone(s) you use. Make sure at least one token can also read SSL settings (the “SSL and Certificates Read” or Zone Settings Read permission), because the installer checks the SSL mode (and, for proxied zones, Universal SSL) with the zone token and falls back to the DNS token on a 401 or 403. If neither can read them, the error asks you to verify manually.

How you provide them:

  • Only through environment variables or the hidden interactive prompt. The --cloudflare-*-token flags are refused with E_CLI because command-line arguments are visible to other users.
  • Both tokens are checked against Cloudflare’s token verification endpoint; a disabled or expired token fails with E_CLOUDFLARE_TOKEN.
  • When Cloudflare exposes the token’s policies, the installer also checks for Zone Read and DNS Write and fails with E_CLOUDFLARE_PERMISSION if they are missing.
Terminal window
export OPENFLARE_CLOUDFLARE_ZONE_API_TOKEN='...'
export OPENFLARE_CLOUDFLARE_DNS_API_TOKEN='...'

The installer stores them as 0600 files in $OPENFLARE_CONFIG_ROOT/secrets/ (cloudflare_zone_api_token, cloudflare_dns_api_token), mounted into Traefik as CF_ZONE_API_TOKEN_FILE and CF_DNS_API_TOKEN_FILE.

Verify mode is the default. The installer reads Cloudflare and checks: one active, unpaused, full-setup zone; the wildcard record; its proxied state; absence of AAAA and CNAME; console and API records; CAA; and, for proxied mode, Universal SSL and the SSL mode. It changes nothing.

Create mode lets the installer manage the wildcard for you. Enable it with --create-dns (also --create-dns-records) or OPENFLARE_CREATE_DNS_RECORDS=1; --no-create-dns-records turns it off.

  • It creates or updates only the wildcard *.<worker-base> A record.
  • A newly created record is DNS only. When it updates an existing record, the proxied state you chose is preserved.
  • It never touches exact records, including the apex and the console or API hosts.
  • It prints a diff first (for example create A ... or update A ... (preserved)).
  • On a terminal it asks you to type yes. Non-interactively you must pass --yes, otherwise the run fails with E_DNS_CONFIRMATION.
  • It supports a dry run.
  • Mutations are retried up to three times. After an ambiguous response it re-reads Cloudflare state, and it fails closed on conflicts. If retries are exhausted, re-run the installer to reconcile.

--skip-dns-check skips verification and marks the result DNS_CHECK_SKIPPED. Use it only when you know the records are right.

After the records pass the API checks, the installer probes real DNS using random names such as install-probe-<hex>.<worker-base>, plus the console host (and API host if set):

  1. An authoritative query against the zone’s Cloudflare nameservers using dig, if dig is installed (4 attempts, 2 seconds apart).
  2. A recursive query through DNS-over-HTTPS (6 attempts, 5 seconds apart).

In DNS-only mode the answer must be exactly your public IPv4. In proxied mode it must fall inside Cloudflare’s edge ranges and must not be your origin address. A failure is reported as E_DNS_PROBE.

You can reproduce this yourself:

Terminal window
dig +short console.example.com
dig +short anything.example.com
dig +short @<cloudflare-nameserver> anything.example.com
Error Likely cause Fix
E_IPV6_UNSUPPORTED An AAAA record exists on the wildcard or console/API host Delete the AAAA record and re-run
E_CLOUDFLARE_DNS Missing wildcard, several A records, a CNAME, or an exact record that differs from the public IP Make the wildcard a single A record equal to the public IP
E_CLOUDFLARE_ZONE Zone not found, inactive, paused, found more than once, or not a full setup Activate the zone with Cloudflare nameservers
E_CLOUDFLARE_SSL Proxied mode with Universal SSL off, no active cert pack, or mode not Full (strict) Enable Universal SSL and set SSL/TLS to Full (strict)
E_CLOUDFLARE_CAA CAA records do not authorize the CA Add a CAA record for letsencrypt.org (or your private CA)
E_CLOUDFLARE_TOKEN / E_CLOUDFLARE_PERMISSION Token disabled, expired or too narrow Recreate the token with the scopes above
E_PUBLIC_IP / E_IPV4 Detection disagreed, address not local, or not public Pass --public-ipv4, or fix NAT
E_DNS_PROBE Record not yet propagated, or proxied state does not match expectations Wait and re-run; compare dig output with the table above
E_HOST_CONFLICT Console, API or webhook host is multi-level under the worker base domain Use a single-label host