Custom domains and certificates
Use this when a tenant’s custom domain stays pending_verification, turns failed, or is verified but not served. It also covers the alerts custom_domain_unrouted, ingress_certificate_invalid and ingress_certificate_expiring.
Internals
pl domain addstores apending_verificationclaim with a token.- Every 5 s the scheduler checks up to 8 due claims against
PUSHLEFT_DOMAIN_VERIFY_NAMESERVER. It looks for TXT_pushleft-challenge.<host>= token, or CNAME<host>→ the environment’s preview hostname. - Misses back off from 15 s to 10 min. A claim fails after 72 h.
- A verified name is routed with the next release, or attached to the live one.
- The gateway activates the route and sets the claim
active. The agent adds the name to Caddy’sapps.tls.certificates.automate. - Caddy orders the certificate (HTTP-01 on port 80 or TLS-ALPN-01 on 443) and renews it itself.
- Preview hostnames use the operator wildcard (
PUSHLEFT_INGRESS_WILDCARD_CERT_FILE/_KEY_FILE). The agent reloads it within 30 s of a file change.
A wildcard claim (*.shop.example.com, migration 0099) works differently:
- Only the TXT record on its base name proves it (
_pushleft-challenge.shop.example.com). - It is routed only after the tenant uploads its origin certificate:
pl domain certificate <id> --cert --key. The certificate is usually a Cloudflare Origin CA certificate behind Cloudflare’s edge, with SSL mode Full (strict). - The key is stored in Vault. The gateway wraps it for the publishing node at lease time.
- The agent loads it into
apps.tls.certificates.load_pem. Caddy never runs ACME for a wildcard.
The design is in architecture.md, paragraph “Ingress TLS”.
Before you start
- Get a shell on the scheduler host and on the ingress host (Caddy admin on
localhost:2019). - Have the claim ID from the tenant (
pl domain list).
1. Look at the claim
-
Show the claim. The output has the status, the method, the attempts, the last error, the next check and every event:
pl domain show <id> -
Go to the section for the status you see.
2. pending_verification or failed
-
On the scheduler host, run the scheduler’s exact check. It uses the same resolver and the same code:
PUSHLEFT_DOMAIN_VERIFY_NAMESERVER=<as configured> pushleft-scheduler check-domain <hostname> <token> <preview-hostname> -
Query the records yourself:
dig +short TXT _pushleft-challenge.<hostname> @<resolver> dig +short CNAME <hostname> @<resolver> -
Find the error below and do what it says.
| Error | Cause | Action |
|---|---|---|
no TXT ... and no CNAME | The record is missing, in the wrong zone, or quoted oddly. The value must equal the token exactly (surrounding spaces are ignored). | Ask the tenant to fix the record. Negative caching can delay a fresh record for the zone’s SOA minimum TTL. |
DNS lookup failed: ... timed out or rcode 2 | Resolver trouble. | Point PUSHLEFT_DOMAIN_VERIFY_NAMESERVER at a working recursive resolver and restart the scheduler. Checks resume by themselves. |
DNS answer was truncated | The TXT set is too large for UDP. TCP fallback is not implemented. | Ask the tenant to remove unrelated TXT records at _pushleft-challenge.<host>. |
failed: hostname is already verified by another organization or environment | Another tenant or environment holds the name. Pushleft has no takeover flow. | Confirm who controls the zone today before you change anything. If the other claim is stale, its owner removes it (pl domain remove). An operator does not edit another tenant’s row. |
failed: verification window expired | 72 h passed. Claims never move back to pending. | The tenant fixes DNS, runs pl domain remove <id>, then pl domain add again (new claim, new token). |
failed: not a valid custom domain outside the preview base domain | The name is under PUSHLEFT_PREVIEW_BASE_DOMAIN. | None. Names under the preview base domain are refused by design. |
lapsed (ownership no longer proven) | Three daily re-checks in a row failed (migration 0046). Its routes drained and the name is free. | If the tenant still owns it, they restore the record, run pl domain remove <id>, then pl domain add. Do not move the row back: the fence trigger refuses it. |
A verified claim with a last_error and custom_domain_recheck_failed events is on its way to lapsed.
3. verified but not served (custom_domain_unrouted)
The environment needs a live release with ready web instances.
- Open Deployments in the Fleet app. Filter by organization and open the live deployment of the environment.
- Find the hostname under Routes. The row shows its node and status.
- If the hostname is not listed, or
pl domain showhas acustom_domain_route_failedevent, ask the tenant to runpl up. The scheduler attaches one route per (live deployment, hostname), only once. A failed route stays failed for that release, andcustom_domain_route_failedholds the agent error. - If the agent error is
ingress_tls_unconfigured, regenerate the base config withpushleft-agent ingress-caddy-configand load it (section 5). The cause is an agent without TLS ingress, or a server holdingpushleft-ingress-routerthat is not HTTPS-only.
4. Served but the certificate is wrong (ingress_certificate_invalid)
-
Check what the ingress serves:
openssl s_client -connect <ingress>:443 -servername <hostname> -verify_hostname <hostname> </dev/null | openssl x509 -noout -subject -issuer -enddate -
Check that
automatelists the custom hostname:curl -s localhost:2019/config/apps/tls/certificates/automate -
Read Caddy’s ACME attempts and errors:
journalctl -u pushleft-ingress-caddy | grep '"identifier":"<hostname>"' | tail -
Find the case below.
Custom domain, no certificate yet. Caddy retries with backoff. The usual causes:
- DNS does not point at this ingress yet.
- Port 80 or 443 is blocked from the internet.
- CA rate limits. Let’s Encrypt allows 50 certificates per registered domain per week and 5 failed validations per hostname per hour.
Fix the cause. Caddy picks it up on its next retry, so you do not need a restart.
The name is missing from automate. The route is not published: go to section 3. Never add names to automate by hand. Pushleft treats that list as its own.
Wildcard custom domain. The newest upload serves it.
-
Find the newest upload.
pl domain show <id>printsorigin_certificatewith itssha256andnot_after. -
Check that
load_pemlistshost:<wildcard>with that SHA-256:curl -s localhost:2019/config/apps/tls/certificates/load_pem | jq '.[].tags' -
Read the agent error, if there is one:
origin_key_unavailable: Vault or the gateway delivered no key.origin_certificate: the upload expired or does not name the wildcard.- Behind Cloudflare, a 526 at the edge means the origin certificate is missing or wrong on this ingress.
A newer upload republishes the wildcard’s live routes at a new generation within one scheduler pass (custom_domain_certificate_routing event). If that publication fails, the old certificate keeps serving. The scheduler tries again only after the next upload or pl up.
Preview hostname. The wildcard does not cover the name (it covers one label under *.<base> only), or the file is expired. Install a renewed wildcard (section 5).
5. Wildcard renewal (ingress_certificate_expiring)
In production, renewal is automatic. On the control-plane host (pl-cp), pushleft-wildcard-renew.timer runs scripts/wildcard-renew.sh daily (wildcard.env.example):
- It runs lego with DNS-01 through Cloudflare. The token has DNS edit on the platform zone only, and stays on
pl-cp. - It renews when less than 30 days remain.
- It installs
apps.*for the agent gateway andcp.*for the control-plane Caddy, then reloads.
Ingress nodes with PUSHLEFT_INGRESS_WILDCARD_FROM_GATEWAY=1 fetch the apps wildcard every 30 s from GET /v1/agent/ingress/wildcard. That endpoint answers active application nodes only. The nodes replace their files in place, keep each file’s mode and owner, and load it.
Tested on 2026-10-29 against Let’s Encrypt’s staging CA and the real Cloudflare zone. The test covered issue, a run with nothing due, a forced renewal with a new serial, and a key that matches its certificate.
If the timer failed:
-
Read lego’s last lines:
journalctl -u pushleft-wildcard-renew -
Read the full log under
/var/lib/pushleft-wildcard/.
To replace the wildcard by hand (staging, or a replacement certificate):
- Write the new certificate and key next to the old ones.
- Use
mvto put them over the configured paths.mvrenames atomically on the same filesystem. - Keep the old files’ owner and mode: on an application node the key is
0640 root:caddyand the certificate0644(/etc/pushleft/ingress/wildcard.keyand.crt). Caddy must read both. - Wait up to 30 s for the agent log line
ingress wildcard certificate loaded (sha256:…). - Check the served certificate with the
openssl s_clientline in section 4. - If the agent refuses it (
wildcard_certificateon the next publication), restore the old files. The new certificate is expired or does not cover*.<base>.
Never paste the key into the admin API, events or tickets. The agent passes only its path to Caddy.
To reload the whole ingress config (lost host, corrupt config):
-
Print the base config:
pushleft-agent ingress-caddy-config [--acme-email …] > /etc/pushleft/ingress/caddy.json -
Restart Caddy:
systemctl restart pushleft-ingress-caddy. The unit runscaddy run --resume, so it loads its autosave (/var/lib/caddy/caddy/autosave.json) when one exists and the base config otherwise. For a corrupt config, move the autosave aside first, then republish routes (ingress host failure). -
Wait for the agent’s next 30 s tick. It restores the wildcard entry.
Custom-domain certificates come back from Caddy’s storage without a new order, if /var/lib/caddy survived.
6. Removing a domain
- The tenant runs
pl domain remove <id>. This setsremoved. - The next scheduler pass drains its routes.
- The agent drops the name from
automateafter its last route is gone.
The certificate stays in Caddy’s storage until it expires. The claim and its events stay as history.
Check it worked
pl domain show <id>showsactive.- The
openssl s_clientline in section 4 shows the right subject and anenddatemore than 14 days away. custom_domain_unroutedandingress_certificate_invalidclear.