Skip to content

acme-dns

An acme-dns server, pinned by tag and digest: v2.0.2's source, built by platform-images with the one fix no release carries yet, so it renews its own API certificate while it runs (acme-dns/acme-dns#410). It answers the DNS-01 checks of the wildcard certificates dotdash servers and relays take under cert_issuer=acme-dns: setting a server or relay on it is in dotdash's Certificates. Caddy stands in front of its API on port 443: it holds the API's certificate and decides who may register.

Run your own: whoever runs an acme-dns server can answer your domains' checks, and the public one is meant only for testing.

Install

Give it a machine of its own: the NS record that delegates its zone makes its address public, so not a dotdash server or relay, nor the manager's machine. Its zone goes under a domain apart from the servers' and the relays', such as auth.example.org: every domain it serves points a public CNAME into that zone, and one under the servers' domain would name it from the relays'.

  1. Firewall: open 53/udp, 53/tcp and 443/tcp in the provider's firewall, and install Docker and morzer as on every dotdash machine.
  2. DNS, at example.org's DNS host, before the first apply:

    acme-ns.example.org.  A   <its IP>
    auth.example.org.     NS  acme-ns.example.org.
    

    The nameserver is outside the zone it serves, so the delegation needs no glue record, which some DNS hosts can't make.

  3. Install:

    sudo morzer init --release oci://ghcr.io/morzecrew/dotdash-utils/acme-dns:stable \
      --domain auth.example.org --recovery-recipient age1… \
      --set address=<its IP> --set nameserver=acme-ns.example.org
    sudo morzer apply
    

    address must be on the machine's own interface (ip -4 addr): ports 53 and 443 are published on it alone, apart from a local resolver on 127.0.0.53. apply waits for the API's certificate, which Caddy takes for auth.example.org from Let's Encrypt over TLS-ALPN-01, on port 443 itself, so it succeeds only once the NS record above resolves and 443 is reachable from the internet. Port 80 is never used.

  4. Register each parent, below.

init prints the release's signing key and trusts it from then on. To check even this first release, add --signing-key with the release key this repository publishes.

Parameters

Set one with sudo morzer config set <name>=<value>.

Name Default
address none, given at init the machine's public IPv4 address: the zone answers it for its own name, and ports 53 and 443 are published on it alone, apart from a local resolver's 127.0.0.53:53. It must be on the machine's own interface (ip -4 addr)
nameserver none, given at init the name the zone's NS record at your DNS host points to, such as acme-ns.example.org, with an A record for address there; outside the zone, so the delegation needs no glue record
api_tls letsencrypt letsencrypt: the API on 443 under a certificate Caddy takes for the zone's name from Let's Encrypt over TLS-ALPN-01, on 443 itself; none: plain HTTP on 443, for a test machine only
registration false true: the API takes new registrations from anyone. Turn it on only while you run register, then off again. Off, a request bearing the register_token secret still registers. Registrations already made keep working either way

Secrets

Name
register_token optional: lets a request to /register through while registration is off, sent as Authorization: Bearer <token>. dotdash's manager sets it when it follows this machine; set by hand, a random string of at least 32 characters. Unset, only registration=true opens /register

Registering a parent

Each parent a wildcard is over, such as s.example.net for *.s.example.net, registers once:

sudo morzer config set registration=true
sudo morzer task run register --output -- s.example.net
sudo morzer config set registration=false

register prints the CNAME for the parent's DNS host and the acme_dns secret for each machine under it (Certificates). With registration=false it says to turn registration on, and does nothing. Registration is off by default, as anyone who reaches port 443 could otherwise register, each time costing a password hash and a row on a small machine.

Registering through the API

Caddy answers every request on port 443. It passes /update and /health to acme-dns for anyone, as acme-dns checks each registration's own key there. /register, and any other path, it passes only while registration=true, or to a request that carries Authorization: Bearer <register_token>; anything else gets a 403. An unset register_token matches no request, not even a bare Bearer.

dotdash's manager sets register_token itself when it follows this machine, below, and registers each parent through the API with it. To register that way without a manager:

openssl rand -hex 24 | sudo morzer secret set register_token
curl -X POST -H "Authorization: Bearer <the token>" https://auth.example.org/register

The register task above still works by hand, with registration=true, token or not.

Caddy sets X-Forwarded-For to the address each request comes from, replacing any a client sends, and acme-dns checks a registration's allowfrom against it.

A sync hint for dotdash's manager

The same install can hold the sync hint: a name in its zone whose TXT the manager changes after each publish, so machines fetch within a minute and otherwise leave the bucket alone. It is a registration of its own, so its credential can't answer a certificate's check, nor a certificate's change the hint:

sudo morzer config set registration=true
sudo morzer task run register --output -- --hint
sudo morzer config set registration=false

Paste the line it prints into the manager. Machines read the name itself, so nothing goes into any zone at your DNS host.

Following dotdash's manager

The machine can follow dotdash's manager like any other: the manager may set register_token here, and nothing else, and the machine tells it, after every change, what the facts task prints:

{"zone": "auth.example.org", "nameserver": "acme-ns.example.org", "address": "203.0.113.7", "api_tls": "letsencrypt", "token": true}

token says whether register_token is set. The token itself is never printed.

One install for servers, another for relays

Each parent's _acme-challenge CNAME is public and names the zone it points into. With the servers' and the relays' parents in one zone, anyone who reads both records sees that they belong together, even with the parents kept apart. To keep relays from pointing at the servers, give each side its own install, with its own zone under its own domain, on its own machine.

Tasks

Task
register --output -- <parent> registers a parent, with registration=true: prints its CNAME and the acme_dns secret of every machine under it
register --output -- --hint registers dotdash's sync hint, with registration=true: prints the JSON the manager takes, the name machines read included
facts --output prints the zone, nameserver, address and api_tls as JSON, and whether register_token is set, never the token: what the machine tells a manager it follows

Health

doctor and each apply pass while the zone answers over DNS, and the API over HTTPS through Caddy under its certificate. Before the first certificate, apply waits for the NS record to delegate the zone here.

Its registrations are in its data volume, and Caddy's certificate in its own; morzer's backups hold both. Lose the registrations and every parent registers again, with a new CNAME and a new secret on each machine.

Moving from dotdash's acme-dns

This is the bundle dotdash released as ghcr.io/morzecrew/dotdash-acme-dns, moved here under the same product name, so an install keeps its registrations. It is signed with this repository's key, and its versions start again below dotdash's, so trust the key and name the older version:

sudo morzer release trust add <the release key, from this repository's README>
sudo morzer config set update.channel=oci://ghcr.io/morzecrew/dotdash-utils/acme-dns:stable
sudo morzer update --stage
sudo morzer update --to <this repository's version> --allow-older