pushleft
Deploy your first app
Manual contents
Handbook
HandbookPushleftArchitecture
Operate
Install the control planeYour own serversFleetOperations and alertsAuthenticationAccess gateDomains and DNSUsage and budgetsScheduled jobsAbuse controlsAI provider proxyCustomer mailErrors and performanceLogs and metricsRetentionObject storageContainer registryGit server
Develop
The .pl.yaml manifestOnboard with an AI agentThe pl up demoBuild executorSource ingestionAgent gatewayManaged databasesSecurity findingsTunnels and shellsDev workspacesPrivate hostnamesMesh coordinatorsDesign baseline
Runbooks
Control-plane host failoverControl-plane PostgreSQL failoverControl-plane PostgreSQL restoreCustom domains and certificatesGateway key compromiseIngress host failureNode busyNode disk fullNode drain and replacementNode lostRegistry outageHetzner Robot hostsSecret rotationSecurity incidentStaging fleet on ProxmoxStaging build cacheStuck deploymentVault/OpenBao backup and recovery
More
CI pipelines
Manual · docs/runbooks/custom-domain-verification.md

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 add stores a pending_verification claim 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’s apps.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

  1. 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>
  2. Go to the section for the status you see.

2. pending_verification or failed

  1. 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>
  2. Query the records yourself:

    dig +short TXT _pushleft-challenge.<hostname> @<resolver>
    dig +short CNAME <hostname> @<resolver>
  3. Find the error below and do what it says.

ErrorCauseAction
no TXT ... and no CNAMEThe 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 2Resolver trouble.Point PUSHLEFT_DOMAIN_VERIFY_NAMESERVER at a working recursive resolver and restart the scheduler. Checks resume by themselves.
DNS answer was truncatedThe 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 environmentAnother 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 expired72 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 domainThe 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.

  1. Open Deployments in the Fleet app. Filter by organization and open the live deployment of the environment.
  2. Find the hostname under Routes. The row shows its node and status.
  3. If the hostname is not listed, or pl domain show has a custom_domain_route_failed event, ask the tenant to run pl up. The scheduler attaches one route per (live deployment, hostname), only once. A failed route stays failed for that release, and custom_domain_route_failed holds the agent error.
  4. If the agent error is ingress_tls_unconfigured, regenerate the base config with pushleft-agent ingress-caddy-config and load it (section 5). The cause is an agent without TLS ingress, or a server holding pushleft-ingress-router that is not HTTPS-only.

4. Served but the certificate is wrong (ingress_certificate_invalid)

  1. Check what the ingress serves:

    openssl s_client -connect <ingress>:443 -servername <hostname> -verify_hostname <hostname> </dev/null | openssl x509 -noout -subject -issuer -enddate
  2. Check that automate lists the custom hostname:

    curl -s localhost:2019/config/apps/tls/certificates/automate
  3. Read Caddy’s ACME attempts and errors:

    journalctl -u pushleft-ingress-caddy | grep '"identifier":"<hostname>"' | tail
  4. 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.

  1. Find the newest upload. pl domain show <id> prints origin_certificate with its sha256 and not_after.

  2. Check that load_pem lists host:<wildcard> with that SHA-256:

    curl -s localhost:2019/config/apps/tls/certificates/load_pem | jq '.[].tags'
  3. 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 and cp.* 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:

  1. Read lego’s last lines:

    journalctl -u pushleft-wildcard-renew
  2. Read the full log under /var/lib/pushleft-wildcard/.

To replace the wildcard by hand (staging, or a replacement certificate):

  1. Write the new certificate and key next to the old ones.
  2. Use mv to put them over the configured paths. mv renames atomically on the same filesystem.
  3. Keep the old files’ owner and mode: on an application node the key is 0640 root:caddy and the certificate 0644 (/etc/pushleft/ingress/wildcard.key and .crt). Caddy must read both.
  4. Wait up to 30 s for the agent log line ingress wildcard certificate loaded (sha256:…).
  5. Check the served certificate with the openssl s_client line in section 4.
  6. If the agent refuses it (wildcard_certificate on 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):

  1. Print the base config:

    pushleft-agent ingress-caddy-config [--acme-email …] > /etc/pushleft/ingress/caddy.json
  2. Restart Caddy: systemctl restart pushleft-ingress-caddy. The unit runs caddy 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).

  3. 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

  1. The tenant runs pl domain remove <id>. This sets removed.
  2. The next scheduler pass drains its routes.
  3. The agent drops the name from automate after 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> shows active.
  • The openssl s_client line in section 4 shows the right subject and an enddate more than 14 days away.
  • custom_domain_unrouted and ingress_certificate_invalid clear.
Rendered from the repository at build time. Edit docs/runbooks/custom-domain-verification.md to change it.