Skip to content

HTTPS and DNS

Two separate mechanisms make https://myshop.rex work, and it is worth knowing which is which when one of them breaks.

rexenv runs a small DNS server that answers *.rex with 127.0.0.1, and writes /etc/resolver/rex so macOS asks it for that TLD. That file is the one-time admin prompt on first run.

No /etc/hosts editing, and no entry to add per site: a new site resolves the moment it exists.

.rex is the always-installed backbone, but the default TLD for new sites is configurable — .test, or anything else. Picking one installs its resolver file the same way, with one admin prompt at that moment.

Terminal window
rex tld --set test

rexenv generates a certificate authority on your machine and asks, once, for permission to trust it in your login keychain. Every site then gets a leaf certificate signed by that CA, with a wildcard SAN for subdomain multisite.

The result is a real green lock — not a bypassed warning, not an exception you clicked through.

Three properties worth stating plainly:

  • The CA signs only your local sites. It is not a general-purpose authority for your machine.
  • The private key never leaves your Mac and is not shared between machines.
  • Trust lives in your login keychain, not the System keychain — user-level blast radius, and removable without admin rights.

Leaves are issued for under 398 days, because Safari and WebKit reject longer-lived certificates outright — with the CA trusted and Chrome perfectly happy, Safari would still refuse. Regenerate one at any time:

Terminal window
rex site cert myshop.rex --regenerate

Caddy terminates TLS on ports 80 and 443, then forwards to the shared nginx by hostname. Its admin interface is a unix socket with 0600 permissions, never TCP.

That last point is a security property, not a preference: a TCP admin API on a root-owned proxy is arbitrary file read and write as root for anything that can reach it. rexenv never binds or queries the conventional TCP admin port, which also means it can never reach into a Caddy you run yourself.