stretch.codes
ByAndrew McCallum

Public Names, Private Servers

Real HTTPS for self-hosted apps without opening a single port, and the decisions that make it work

October 24, 2026

I used to reach the apps on my home server by connecting to Tailscale and typing the server's local IP address and a port, something like http://192.168.x.y:8989. Tailscale's MagicDNS name would have spared me the IP address, but it would still have been a port number to remember for every app, and a browser warning on every page.

They now live at addresses like https://grafana.home.stretch.codes, with a real Let's Encrypt certificate, and none of them can be reached from the internet or the local network. The setup itself is small. What I want to share is the handful of ideas that make it work.

The name can be public even when the server isn't

The core of it sounds wrong at first. It's an ordinary, public DNS record:

*.home.stretch.codes.  300  IN  A  100.x.y.z

That address is the server's IP on my Tailscale network. Anyone can look up grafana.home.stretch.codes, but the answer sits in 100.64.0.0/10, a range that isn't routable on the internet. Only devices on my tailnet have a route to it. The name is public; the server isn't.

It's natural to reach for private DNS here, a resolver on your own network that only your devices use. Public DNS turns out to be better. The names work on every device without configuring anything, and they keep working if my home DNS server is having a bad day. Publishing the address gives nothing away either, because it's useless to anyone outside the tailnet.

The full path of a request ends up looking like this:

phone ──DNS──▶ public record ──▶ 100.x.y.z
phone ══ Tailscale tunnel ══▶ server:443 ──▶ Traefik (loopback) ──▶ app container

A wildcard certificate hides what you run

Let's Encrypt normally proves you control a domain by connecting to it, which can't work for a server nothing can connect to. The alternative is the DNS-01 challenge: the server creates a TXT record at _acme-challenge.home.stretch.codes through the DNS provider's API, Let's Encrypt checks for it, and the server never accepts a connection at all.

DNS-01 is also the only way to get a wildcard certificate, and that matters for a less obvious reason. Every certificate Let's Encrypt issues is published in public Certificate Transparency logs, searchable on sites like crt.sh. With one certificate per app, anyone could look up my domain and read off a list of everything I self-host. The wildcard only ever reveals *.home.stretch.codes.

Certificates being public is good for the web, but it's worth remembering that every name you put on one becomes public too.

Your DNS key shouldn't be able to touch your website

DNS-01 means the home server holds a key to the DNS provider. Most guides use a key with full access to the zone, which means a compromised home server could repoint your website or your email.

Route 53 can do much better with two lesser-known IAM condition keys that restrict which record names and types a key may change. This key can write exactly one record:

Condition = {
  "ForAllValues:StringEquals" = {
    "route53:ChangeResourceRecordSetsNormalizedRecordNames" = ["_acme-challenge.home.stretch.codes"]
    "route53:ChangeResourceRecordSetsRecordTypes"           = ["TXT"]
  }
}

ForAllValues means every change in a request has to match, so a batch that slips in any other record is refused as a whole. The key also gets read access to the zone and route53:GetChange to watch propagation, and nothing else. The worst a thief could do with it is get a certificate for names only my tailnet can reach.

I did weigh up getting rid of the stored key entirely, and both options were worse:

  • GitHub Actions with OIDC could renew the certificate with no long-lived secret, but then the certificate's private key passes through CI on every renewal. That's a more valuable secret than a key that can write one TXT record.
  • AWS's exportable public certificates remove Let's Encrypt from the picture, but they cost money and you still have to install every renewal yourself.

OIDC is the right answer when a trusted third party can vouch for the machine, and nothing vouches for a Mac mini in a flat. A tightly scoped key was the honest trade.

Don't bind to an address that might not exist yet

A reverse proxy, Traefik in my case, presents the certificate and routes each name to its container. The obvious way to expose it is to publish its port on the Tailscale IP. That works right up until the first reboot where Docker starts before Tailscale: the address doesn't exist yet, the port binding fails, Docker doesn't retry, and everything stays down until someone notices.

So Traefik listens only on loopback, and Tailscale hands it the tailnet's port 443:

tailscale serve --bg --tcp=443 tcp://127.0.0.1:4443

--tcp passes the raw connection through, so TLS reaches Traefik untouched, and Tailscale re-applies the setting every time it starts. The two no longer depend on starting in the right order. More generally, binding a service to an interface owned by a different piece of software couples their startup in a way that's easy to miss until a reboot.

Moving everything onto loopback also forced me to audit what my server was exposing. Publishing a port on 0.0.0.0 means every network the machine is on, not just the one you had in mind, and my admin UIs had been published that way.

What tripped me up

Apps with their own anti-forgery checks. One app worked in the browser, but its Android client got "Access denied". The client sent the address with :443 on the end, and the app's CSRF protection and Host header validation treated that as a different site. Behind a reverse proxy that only forwards one exact hostname, on a network only I can reach, those checks were adding friction rather than protection, so I turned them off. I'd turn them back on before ever making that app public.

AWS validates before it authorises. My first Terraform apply failed on an invalid tag value (IAM doesn't allow * in tags). It's tempting to read that as a sign the permissions are fine, and they weren't. AWS checks a request's format before checking whether you're allowed to make it, so a validation error tells you nothing about permissions.

A plan that passes isn't an apply that will. The CI role couldn't create IAM users, yet the plan passed, because planning a brand new resource never calls AWS. The missing permission only surfaced at apply time.

An open port proves very little. Until Let's Encrypt comes through, Traefik serves a self-signed fallback, so "something answers on 443" means nothing. My deploy waits until curl, with no -k, accepts the certificate for a real hostname. Checking what the user would experience beats checking that a process is running.

What I'd take away

None of the pieces is complicated. What made the difference was a few ideas a recipe tends to skip: a public name can point somewhere private, certificates are public and a wildcard keeps your inventory private, a DNS key can be scoped to a single record, and services shouldn't bind to addresses another program owns.

The result has the convenience of public services, short names and HTTPS, with none of the exposure. Adding the next app is a three-line route.