Repository navigation
Edge and TLS
Live. Unlike the rest of this wiki, this is deployed and serving:
caddy/in the repository, running from/var/caddyon the VPS.
A master Caddy owns ports 80 and 443 for the whole host, terminates TLS and HTTP/3, and routes by Host header to each project's own web server. It holds no project's web configuration.
minecraft.*.nip.io ──▶ 127.0.0.1:8801 minecraft-caddy
:80 :443 master Caddy ─┬ roomcad.*.nip.io ──▶ 127.0.0.1:8443 roomcad-caddy (https)
TLS + h3 ├─── xaios.*.nip.io ──▶ 127.0.0.1:8090 xaios-caddy
└─ <next>.*.nip.io ──▶ 127.0.0.1:88xx <next>'s own server
All three hold real Let's Encrypt certificates, issued automatically via TLS-ALPN-01 now that one process owns 443. No ports in any URL.
Ports 80 and 443 can only be held once, and Let's Encrypt validates on nothing else — HTTP-01 needs 80, TLS-ALPN-01 needs 443, and DNS-01 is impossible because nip.io is a public wildcard resolver whose zone we do not control. So whichever process holds those ports is the only one on the host that can obtain a certificate.
Before this, each project worked around that individually: RoomCAD served on 8443 with a certificate renewed by a hand-written script, and the XAIOS updater served plain HTTP on 8090 with no TLS at all. Centralising the two ports means every project gets automatic HTTPS on a clean URL instead.
nip.io accepts arbitrary prefixes against one IP, so every project can have its own hostname on this host.
The edge holds no project's web configuration. Roots, headers, cache policy, API routes and deploys all stay inside the project that owns them; an entry in projects/ is four lines saying which hostname goes to which port.
That boundary is not tidiness. This host previously ran one shared /etc/caddy/Caddyfile holding several projects' real configurations, and each project's deploy overwrote the others' — plus a certificate symlinked into a third project's tree that dangled when that tree was restructured. RoomCAD's own config documents the episode. A routing entry is not something a deploy rewrites, so that failure cannot recur.
Each project keeps its own Caddy: own binary or the system one, own unix user, own storage, own admin socket, own systemd unit. Minecraft follows the same convention — see site/.
| Path | Purpose |
|---|---|
caddy/Caddyfile |
Master config: global options and one import. Adding a project never edits it. |
caddy/projects/*.caddy |
One fragment per project, owned by that project. |
caddy/projects/EXAMPLE.caddy.template |
Starting point for a new project. |
caddy/systemd/caddy.service.d/override.conf |
Points the packaged unit at /var/caddy. |
caddy/scripts/validate.sh |
Validates master and every fragment. No root. |
caddy/scripts/test-edge.sh |
Runs the real config against a scratch root and stub API. No root. |
caddy/scripts/install.sh |
Stages onto the VPS. Starts nothing, takes no port. |
caddy/MIGRATION.md |
Taking 80 and 443 from whatever holds them now. |
Import paths are relative to the Caddyfile, so the same config validates from a checkout and runs from /var/caddy.
Environment indirection. Paths, upstreams and hostnames use {$VAR:default}, with production values as the defaults. The overrides are what let the config be validated and exercised without root — and a config that can only be checked on the production host is a config nobody checks. This is v1's pattern, and it was one of the things v1 got right.
Forward the client's Host. header_up Host {host} on every routing entry. Without it Caddy sends the dial address upstream, so a project whose own config matches a specific hostname matches nothing and returns a bare empty 200 — success status, no body, nothing logged as an error. RoomCAD hit exactly this during deployment; projects matching any host hide the bug entirely.
bind restricts the interface, not the site address. Writing a site address as 127.0.0.1:8801 does not listen on loopback — Caddy reads the host part as a Host matcher and still binds all interfaces, answering only requests whose Host header is literally 127.0.0.1. Use bind 127.0.0.1 with a port-only address.
Order-sensitive directives go inside route. Caddy sorts directives by its own standard order, not the order written. A respond guarding sensitive paths, placed beside handle, executes after file_server — serving the very files it exists to block, with a 200 and no error anywhere. This was a real bug in the first draft, caught by test-edge.sh rather than in production.
Only the master does TLS. A project running its own Caddy needs auto_https off, or it attempts ACME, fails because it cannot bind 80 or 443, and retries forever.
Enabled by default in Caddy 2.6 and later; the old experimental_http3 flag no longer exists. Set explicitly in the master's global options so it survives review.
Two operational requirements that are easy to miss:
- UDP 443 must be open in the firewall. QUIC runs over UDP on the same port number as the TCP listener. Opening only TCP produces a site that works while silently never using HTTP/3.
-
The first request is always TCP. The browser learns about HTTP/3 from the
Alt-Svcheader on that response and upgrades afterwards.
Confirmed working by http3check.net for all three hostnames: a QUIC connection established on every attempt, ~89 ms handshake.
Do not verify HTTP/3 from a machine using this VPS as a Tailscale exit node. Its traffic leaves with the server's own public address, so a QUIC request to any hostname here hairpins back into the same host and the reply path breaks. The packets arrive — visible on tailscale0 addressed to the public IP — but nothing answers, and curl --http3-only reports a failure that looks exactly like a firewall block or a broken listener.
TCP survives that hairpin, so HTTP/2 keeps working and only HTTP/3 appears broken. That combination is very easy to misread as a server fault; it cost an hour here.
Trustworthy checks, in order of preference:
- An external checker, which connects from its own network.
- A device on a connection that does not exit through this host — a phone on cellular with Tailscale off.
- On the box itself, which proves Caddy's QUIC stack but not the internet path:
curl -sS --http3-only -o /dev/null -w '%{http_version}\n' https://minecraft.91.99.176.243.nip.ioAll three serve TLS 1.3 with a complete four-certificate chain and verify against the system trust store with no extra flags — no missing intermediate, which is the usual way a site works in curl and fails elsewhere.
No window and no risk:
cp EXAMPLE.caddy.template /var/caddy/projects/myproject.caddy
sudo systemctl reload caddyA reload with an invalid config fails and keeps the running config, so a bad fragment is a failed deploy rather than an outage.
Usually not. A fragment can serve static files and proxy an app directly, which is what minecraft.caddy does — the mod site is static files plus one API route, and a second Caddy would add a process and a hop for nothing.
A dedicated instance earns its place when a project needs its own cache and header policy, independent reloads, a pinned Caddy version, or runs in a container. Decide per project rather than as a rule.
Let's Encrypt allows 50 certificates per registered domain per week. That is comfortable only if nip.io is on the Public Suffix List, making each <name>.nip.io its own registered domain rather than all of them sharing a single bucket with every nip.io user in the world.
It is believed to be listed — that is why nip.io works with Let's Encrypt at all — but verify before a dozen projects depend on it. And do not enable on_demand_tls without an ask endpoint: every hostname under *.91.99.176.243.nip.io points at this host, so anyone could trigger issuance with an arbitrary SNI and exhaust the limit.
The durable answer, if the project count keeps growing, is a domain we control plus a wildcard certificate via DNS-01: one certificate covering everything, no per-hostname issuance, no rate-limit exposure, and no raw IP in any URL a person has to type.
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' \
| sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' \
| sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update && sudo apt install caddyThe development machine should track the same major version so edge tests exercise the behaviour production has.
/var/caddy/projects/ is an assembly point, not a directory this repository owns. Each project installs its own entry there as part of its own deploy, and install.sh writes only the entries this repository ships — it never removes others, so no project's deploy can clobber another's.
This is not theoretical. RoomCAD's entry was kept here at first and went stale within a day: its own project migrated the service to loopback, added flush_interval for its server-sent-events endpoint, and added a :8443 alias so previously shared links keep working. The copy here knew none of that. It has been removed; RoomCAD owns it.
The XAIOS updater's entry is still here only because that project has no repository yet.
| Server | Reachable directly? | Notes | |
|---|---|---|---|
| Minecraft | 127.0.0.1:8801 |
no | Placeholder until the engine exists |
| RoomCAD | 127.0.0.1:8081 |
no | Also answers on :8443 through the master, for links shared before |
| XAIOS updater | 127.0.0.1:8090 |
no | Also served over plain HTTP; see below |
All three send HSTS, nosniff, frame protection and a referrer policy, and none advertise their server software. RoomCAD adds its own CSP.
The updater is also served over plain HTTP on :80, at http://xaios.91.99.176.243.nip.io, without the redirect every other host gets. Its devices have no real-time clock, so they cannot validate a certificate or complete a TLS handshake — redirecting them to HTTPS redirects them to a wall. This is safe for this endpoint specifically because integrity does not rest on the transport: catalog entries carry a sha256, a signature and a key. Browsers still get HTTPS, because the HTTPS response sets HSTS.
That exception costs one thing: the plain-HTTP site occupies :80 for the hostname and swallows /.well-known/acme-challenge/, so HTTP-01 cannot work for it. The entry therefore sets disable_http_challenge and relies on TLS-ALPN-01 — a stated decision rather than a lucky default, which would otherwise fail silently at the first renewal that fell back.
Nothing on this host is reachable by bare IP. Every project is addressed by its nip.io hostname and only that. http://91.99.176.243/ redirects to an address with no certificate — a deliberate dead end rather than a default project — and no port answers a bare-IP request.
The updater's :8090 was the last exception and is now bound to loopback. It stayed open while it was unknown whether any device in the field still fetched from http://91.99.176.243:8090/: the catalogs carry relative paths, so a device's base URL lives on the device and cannot be read from the server, and binding loopback blind risked stopping firmware updates for a fleet that could not be inventoried. Access logging settled it — the only traffic that ever reached the port directly was an internet scanner.
RoomCAD's session cookies survive the extra hop. Its app marks the session cookie Secure based on X-Forwarded-Proto, and its Caddy now forwards the master's value explicitly. It also falls back to rejecting loopback hostnames, so the flag holds even if a future proxy change swallowed the header.
Reconnaissance found the premise wrong: ports 80 and 443 were not in use at all. nginx had held them, was already stopped, but was still enabled — it would have raced the edge for both ports on the next reboot. It is now disabled, left installed with its configuration intact.
Design stage — not implemented
Design
Validation
Trust
Interfaces
Operations
Project
Reference