feat(infra): enable production TLS for Phases 11-12 via coa-manager.duckdns.org

This commit is contained in:
Дмитрий committed 2026-10-09 07:12:42 +05:00
1 parent 42c05c50e7
commit 1dc212968d
16 files changed
+251 -65

No files matched your search

+1 -1
View File
@@ -213,7 +213,7 @@ for the in-world refusal) instead of logging in with the game: the Manager must
## 13. What remains before Relay
1. **TLS** on the node (needs a domain; no custom PKI). Until then the WebSocket is plain, which is safe for what it carries (everything private is inside the Noise channel) but exposes metadata to an on-path observer.
1. **TLS completed**: Public domain `coa-manager.duckdns.org` configured with automatic Let's Encrypt certificates through Caddy. Coordinator connections use `wss://coa-manager.duckdns.org/coord/v1/...` and Registry uses `https://coa-manager.duckdns.org`. Port 80 redirects to 443. The TLS gate passed all 13 checks (see `docs/REGISTRY_DEPLOYMENT.md`).
2. **A game route**: Relay or a direct route. Today only an owner-stated address makes `Join` start the game.
3. **Moving a portable character onto a realm that is not its home** (import, update, session prepare over the channel): the Host side exists in the engine (Phases 7–9) but the messages to carry an offer and its answers between two Managers are not defined; `needs_transfer` says so.
4. **Native login prefill**: the owner's audit run (section 10).
+10 -7
View File
@@ -12,12 +12,10 @@ This file never contains private keys, passwords, DB credentials, transfer PINs,
Registry API Relay Coordinator PostgreSQL Caddy (ingress) monitoring
```
Phase -1 prepared the host. **Phase 10 deployed the Registry and PostgreSQL** (see [REGISTRY_DEPLOYMENT.md](REGISTRY_DEPLOYMENT.md)); no Relay or Coordinator exists yet.
Phase -1 prepared the host. **Phase 10 deployed the Registry and PostgreSQL** (see [REGISTRY_DEPLOYMENT.md](REGISTRY_DEPLOYMENT.md)); **Phase 12 deployed the Coordinator**; and the **Phases 11-12 TLS gate** enabled production HTTPS/WSS ingress.
The VPS is not the source of truth for any player data.
No domain is registered. Until one exists, services are addressed by IP, and Caddy serves plain HTTP on :80.
The design keeps client protocols independent of hostnames so the relay can later be moved to separate nodes and
DNS names (`api.<domain>`, `relay.<domain>`) added without changing the client protocol.
Public domain is `coa-manager.duckdns.org` pointing to `coa-infra-01`. Caddy automatically obtains and renews trusted Let's Encrypt TLS certificates via ACME. HTTP on port 80 redirects to HTTPS on port 443.
## Service architecture
@@ -25,13 +23,15 @@ DNS names (`api.<domain>`, `relay.<domain>`) added without changing the client p
Internet
|
22/tcp -> sshd
80,443/tcp
80,443/tcp (80 redirects to 443; ACME TLS via Let's Encrypt)
v
Caddy (container, network coa-ingress)
|
+--> Registry API (coa-registry:8080, networks coa-ingress + coa-db, no published port)
|
+--> PostgreSQL (coa-postgres:5432, network coa-db only, --internal, no published port)
| |
| +--> PostgreSQL (coa-postgres:5432, network coa-db only, --internal, no published port)
|
+--> Coordinator (coa-coordinator:8081, networks coa-ingress + coa-db, no published port)
```
Rules:
@@ -129,6 +129,9 @@ sudo docker compose logs --tail 50
# PostgreSQL and the Registry (Phase 10): see REGISTRY_DEPLOYMENT.md
cd /opt/coa/postgres && sudo docker compose up -d
cd /opt/coa/registry && sudo docker compose up -d
# Coordinator (Phase 12)
cd /opt/coa/coordinator && sudo docker compose up -d
```
## Backups
+29 -10
View File
@@ -1,16 +1,16 @@
# Registry and Coordinator deployment (Phases 10, 10.1, 11, 12)
# Registry and Coordinator deployment (Phases 10, 10.1, 11, 12, TLS Gate)
How the Registry and the Coordinator run on `coa-infra-01`, how to rebuild or restart them, and what the gates checked. Protocols: [REGISTRY_PROTOCOL.md](REGISTRY_PROTOCOL.md), [CONTROL_PROTOCOL.md](CONTROL_PROTOCOL.md).
Node facts: [INFRASTRUCTURE.md](INFRASTRUCTURE.md), [VPS_BASELINE.md](VPS_BASELINE.md). `<VPS_IP>` is the node's public IPv4 (kept out of git); no secret is in this file.
Node facts: [INFRASTRUCTURE.md](INFRASTRUCTURE.md), [VPS_BASELINE.md](VPS_BASELINE.md). `<VPS_IP>` is the node's public IPv4 (kept out of git); no secret is in this file. Production hostname: `coa-manager.duckdns.org`.
## Topology
```
Internet
| 22/tcp (sshd) 80/tcp, 443/tcp (Caddy, the only container with published ports)
| 22/tcp (sshd) 80/tcp (redirect to 443), 443/tcp (Caddy, the only container with published ports)
v
Caddy :80 /registry/* -> coa-registry:8080 network coa-ingress
:80 /coord/* -> coa-coordinator:8081 network coa-ingress (WebSocket; Phase 12)
Caddy :443 /registry/* -> coa-registry:8080 network coa-ingress (HTTPS; ACME Let's Encrypt)
:443 /coord/* -> coa-coordinator:8081 network coa-ingress (WSS WebSocket; Phase 12)
|
Registry container (coa-registry) +--- network coa-db (internal) ---+
v
@@ -20,8 +20,7 @@ Registry container (coa-registry) +--- network coa-db (internal) ---+
* Registry and PostgreSQL publish **no host port**. `docker ps` shows `8080/tcp` and `5432/tcp` (exposed inside Docker networks only), and `ss -tulnH` lists only 22, 80, 443.
Never add `5432:5432` or `8080:8080`.
* The Registry joins `coa-ingress` (to be reached by Caddy) and `coa-db` (to reach PostgreSQL). PostgreSQL joins only `coa-db`, which is `--internal`.
* Caddy serves plain HTTP on :80 (no domain yet: `auto_https off`, admin API off). Port 443 is allowed by UFW and published by Docker, but nothing listens on it until TLS exists.
**HTTPS is mandatory before the list and the control plane are shown to players outside the test group** (the one open item of Phase 11 and of Phase 12's transport); for these staging gates HTTP is acceptable because every Host request is signed, the public list is public, and everything private on the control plane is end-to-end encrypted inside the WebSocket (an on-path observer of plain HTTP learns that a connection to a realm exists and its size and timing, nothing else). No custom PKI is used or planned: TLS needs a domain name and a normal certificate (ACME through Caddy).
* Caddy serves public HTTPS and WSS on `coa-manager.duckdns.org` with automatic Let's Encrypt ACME certificate management. Port 80 automatically redirects (308 Permanent Redirect) to HTTPS. Certificate state and ACME account metadata are stored in persistent Docker volumes `coa-caddy_caddy_data` and `coa-caddy_caddy_config`.
## Files (in git: `services/coa-registry/deploy/`)
@@ -75,8 +74,8 @@ Staging note: the gate ran with `REGISTRY_REGISTER_BURST=100`; the production de
```bash
cd /opt/coa/registry && sudo docker compose ps && sudo docker compose logs --tail 50 # JSON lines
curl -s http://<VPS_IP>/registry/v2/healthz # {"status":"ok","protocol_version":2}
curl -s http://<VPS_IP>/coord/v1/health # {"hosts":N,"protocol_version":1,"status":"ok"}
curl -s https://coa-manager.duckdns.org/registry/v2/healthz # {"status":"ok","protocol_version":2}
curl -s https://coa-manager.duckdns.org/coord/v1/health # {"hosts":N,"protocol_version":1,"status":"ok"}
sudo sh /opt/coa/registry/src/services/coa-registry/deploy/audit-db.sh # contents audit
```
@@ -146,7 +145,27 @@ Run today with 5000 synthetic realms loaded by `deploy/synthetic.sh load 5000` (
| Filters, bounds, ETag/cache, read-only | pass (`gate11_filters_etag_and_read_only`): search, mode, cap range, module, online players; limits above 100, a repeated or unknown parameter and a foreign cursor → 400; `If-None-Match` → 304; `POST`/`PUT`/`DELETE` on the public paths → 405 |
| The Manager's *Servers* page | pass in the real window against the live Registry: the table, filters, sort headers, module chips and tooltips from the local catalog (an unknown id as plain text), the detail drawer with the compatibility verdict of the selected portable character, "—" for ping |
| Configurable Registry address, none hard-coded | pass (setting + `COA_REGISTRY_URL`) |
| **TLS** | **not done: the node has no domain.** This is the only gate item that cannot be passed without something the project does not have (a domain name). Nothing was invented instead (no self-signed or private CA) |
| **TLS** | **pass**: public domain `coa-manager.duckdns.org` configured; Caddy automatically obtains and renews trusted public Let's Encrypt certificates; HTTP redirects to HTTPS; certificate state persisted across restarts |
## The TLS Finishing Gate (Phases 11 and 12)
Run from an external workstation against `https://coa-manager.duckdns.org` and `wss://coa-manager.duckdns.org`.
| # | Item | Result |
|---|---|---|
| 1 | `https://coa-manager.duckdns.org/registry/v2/healthz` returns Registry v2 health | pass (`{"status":"ok","protocol_version":2}`) |
| 2 | HTTP request redirects to HTTPS | pass (`HTTP/1.1 308 Permanent Redirect` -> `https://coa-manager.duckdns.org/...`) |
| 3 | Public realm browser works through HTTPS | pass (`gate11_filters_etag_and_read_only` over HTTPS) |
| 4 | Host publication / register / heartbeat works through HTTPS | pass (`gate_1_to_12_against_the_node` over HTTPS) |
| 5 | Coordinator Host connection works through WSS | pass (`HostLink` connected to `wss://coa-manager.duckdns.org/coord/v1/host`) |
| 6 | Player → Coordinator → Host control channel works through WSS | pass (`PlayerControl::connect` establishes Noise session over WSS) |
| 7 | Automatic account provisioning works | pass (`ensure_account` provisioned account over WSS) |
| 8 | Existing-account linking works | pass (`link_existing` linked credentials over WSS) |
| 9 | Character claim works | pass (`claim` and `acknowledge` over WSS) |
| 10 | Caddy restart recovers without broken/new certificate | pass (`docker restart` serves cached cert from `/data/caddy/certificates`) |
| 11 | Certificate inspected: hostname, chain, dates | pass (`CN=coa-manager.duckdns.org`, Issuer: Let's Encrypt, Valid until Jan 2027, Verify=True) |
| 12 | External port scan exposes no internal ports | pass (22, 80, 443 open; 2019, 5432, 8080, 8081 closed) |
| 13 | Registry/Coordinator/control-plane regression tests pass | pass (all suites pass cleanly) |
## The Coordinator (Phase 12)
+2 -5
View File
@@ -257,11 +257,8 @@ There is no heartbeat history and no table about players, characters, accounts o
*Servers* is the first page of Player Mode (and available to a Host): a table of the public list (Server, Modules, Cap, Rates, Mode CoA/Wildcard, Ping, Online "N players + M bots"), with search,
filters (mode, level cap range, module, online players) and sortable columns (name, cap, online); the detail drawer shows the rates, the modules and whether the *selected portable character*
can play there, using the existing Phase 7/8 compatibility logic against the capabilities in the record, and the join panel of `docs/CONTROL_PROTOCOL.md`. Module names and tooltips come from the
**local** module catalog; an id the catalog does not know is shown as plain text. Ping shows "—" with an explanation until a real route exists. The Registry address is a setting (and
`COA_REGISTRY_URL` for tests and deployments); nothing is hard-coded. The browse client sends nothing about the player.
**local** module catalog; an id the catalog does not know is shown as plain text. Ping shows "—" with an explanation until a real route exists. The Registry address defaults to `https://coa-manager.duckdns.org` (configurable in settings, and overridable via `COA_REGISTRY_URL` for tests and fixtures); no IP address is hard-coded. The browse client sends nothing about the player.
## 11. Not in this document
The control plane (accounts, character claiming, the Coordinator), Relay, direct-connect optimisation, portable-character transfer to another Manager. **HTTPS**: the staging node serves plain HTTP
(no domain, so no certificate); requests are signed and carry no secret, and the public list is public. TLS is a hard requirement before the list is shown to players outside the test
group, and is the one open item of Phase 11 (see `docs/REGISTRY_DEPLOYMENT.md`). No custom PKI is used or planned.
The control plane (accounts, character claiming, the Coordinator), Relay, direct-connect optimisation, portable-character transfer to another Manager. **HTTPS**: the production node serves public HTTPS on `https://coa-manager.duckdns.org` with automatic Let's Encrypt certificates managed by Caddy; plain HTTP redirects to HTTPS.
+7 -3
View File
@@ -42,8 +42,8 @@ Date configured: 2026-10-06 (UTC)
| Port | Proto | Service |
|---|---|---|
| 22 | tcp | sshd (key only) |
| 80 | tcp | Caddy (answers `/healthz` with `ok`, everything else 404) |
| 443 | tcp | Caddy (published, no certificate/site yet) |
| 80 | tcp | Caddy (redirects HTTP to HTTPS on 443) |
| 443 | tcp | Caddy (Let's Encrypt TLS: `/registry/*` and `/coord/*`) |
Everything else is closed, including 5432, 3306/3307, 2375/2376 (Docker API), 2019 (Caddy admin; admin API is disabled).
@@ -103,8 +103,12 @@ published as `127.0.0.1:<port>:<port>`.
PostgreSQL 17 and the Registry now run (containers `coa-postgres-postgres-1`, `coa-registry-registry-1`); Caddy proxies `/registry/*` to the Registry. Public ports are unchanged (22, 80; 443 is
allowed and published but has no listener until TLS). Details and the gate: [REGISTRY_DEPLOYMENT.md](REGISTRY_DEPLOYMENT.md).
## Phase 12 & TLS gate addendum
The Coordinator (`coa-coordinator-coordinator-1`) runs behind Caddy on `coa-ingress` with no published port. Domain `coa-manager.duckdns.org` is pointed to the VPS, and Caddy manages automated Let's Encrypt TLS certificates on port 443 with persistent `/data` storage across container restarts. Port 80 automatically redirects to HTTPS. Public endpoints are `https://coa-manager.duckdns.org/registry/*` and `wss://coa-manager.duckdns.org/coord/*`. Verified by 13-item external verification gate (see [REGISTRY_DEPLOYMENT.md](REGISTRY_DEPLOYMENT.md) and [CONTROL_PROTOCOL.md](CONTROL_PROTOCOL.md)).
## Open items
- Fill in region, plan/service ID, network limit from the OVH Control Panel.
- Find out what OVH backup/snapshot is actually enabled for this plan (see INFRASTRUCTURE.md, Backups).
- Decide on the public hostname/TLS strategy (no domain yet; Caddy serves plain HTTP on :80).
- [RESOLVED] Decide on the public hostname/TLS strategy: configured `coa-manager.duckdns.org` with Caddy automated Let's Encrypt TLS on 443.