Self Host Wizard Docs

Add a domain and its DNS records

Serve another domain from the box, see the DNS records its owner publishes for web and mail, and choose which domain carries the apps.

Every company domain the box serves is in the state file with the company it belongs to. The box does not register domains and does not change DNS for you: you, or whoever owns the domain, publish the records at the domain's DNS host. thx prints exactly what to publish.

Steps

  1. Add the domain and say which company it belongs to: sudo thx domain add acme.example --org acme. Domain names must be lowercase.
  2. Apply: sudo thx apply. Caddy starts answering for the domain and its www. name, and asks Let's Encrypt for certificates as soon as DNS points at the box.
  3. Print the mail records: sudo thx dns acme.example. Publish each required record at the DNS host. The DNS records reference shows the full output for an example domain, with what each record is for.
  4. Point the web names at the box: an A record for mail.acme.example (it is in the thx dns output), and, only if you want the box to answer there, an A record for the apex and www.
  5. Check the list: sudo thx domain ls.

What the box serves on a company domain

  • acme.example: a placeholder page that says nothing is published there yet, until you serve a website on it with thx site add. If the company already has a website elsewhere, leave the apex A record alone: the box never needs it.
  • www.acme.example: a permanent redirect to the apex.
  • mail.acme.example, autoconfig.acme.example and autodiscover.acme.example: the mail server's name, and the names mail clients look up to configure themselves.

The apps domain

One served domain is also the apps domain, set with sudo thx set site_domain acme.example. Every app lives under it: app.acme.example, crm.acme.example, drive.acme.example and so on. The domain must already be on the box. The set-up wizard checks for a wildcard record, * A pointing at the box's public IP, on the apps domain before it installs the apps, because each app name needs its own certificate. Clearing it with sudo thx set site_domain '' and applying drops every app address from Caddy's configuration, and the IP address serves the set-up wizard again.

Mail records in short

thx dns prints five required records and some optional ones:

RecordWhy
A for mail.the mail server's address; never proxied by a CDN
MXwhere the internet delivers the domain's mail
TXT SPFlets the cloud provider's email service send as the domain; merge with an existing SPF record, never publish two
CNAME DKIMthe email service signs outgoing mail; copy name and value from your cloud console
TXT DMARCstarts at p=none; tighten it once real mail passes SPF and DKIM

The DKIM record appears only after you record it with thx relay dkim, described in mail and the relay.

Removing a domain

sudo thx domain rm acme.example stops serving it. The domain that is the apps domain cannot be removed until you clear site_domain. Mail already received for the domain stays in the mailboxes.

Moving the apps to another domain

Add the new domain, then make it the apps domain and apply:

sudo thx domain add newname.example --org acme
sudo thx set site_domain newname.example
sudo thx apply

Every app moves to <app>.newname.example, and noreply@ and the box's own accounts follow by themselves. People keep the addresses they had; give them new ones with thx user alias add. Everyone signs in again on the new domain. Authenticator-app codes keep working, but passkeys and security keys belong to the old domain, so each person registers theirs again. When nothing uses the old domain any more, remove it as described above.

Facts on this page come from these files in the selfhostwizard repository:

  • cmd/thx/main.go
  • internal/state/state.go
  • internal/maildns/maildns.go
  • internal/webapp/maildns.go
  • pieces/caddy/Caddyfile.tmpl
  • pieces/stalwart/README.md

Updated