From 35073273d12f49f3e23ed367d301f47493aef672 Mon Sep 17 00:00:00 2001 From: Tom Date: Sat, 10 Oct 2026 22:26:28 +0200 Subject: [PATCH] Serve the PocketBase admin at redaktion.elternbeirat-igmh.info - eb-pocketbase joins proxynet so NPM reaches it as eb-pocketbase:8090, and drops the 8090 host port; no service publishes a port on Unraid anymore - docs/deployment.md covers the Strato CNAME, the NPM proxy host and the / -> /_/ redirect (full URL, or nginx adds its :4443 container port) - PB_URL in .env.example and the editor docs point at the subdomain Co-Authored-By: Claude Opus 5.5 --- .env.example | 2 +- compose.yaml | 21 ++++++++--------- docs/deployment.md | 43 +++++++++++++++++++++++++++++++++-- docs/redaktion.md | 2 +- docs/unraid-infrastructure.md | 5 ++-- 5 files changed, 56 insertions(+), 17 deletions(-) diff --git a/.env.example b/.env.example index 80339d9..dd409f2 100644 --- a/.env.example +++ b/.env.example @@ -13,6 +13,6 @@ GITEA_REPO=Tom/Elternbeirat # PocketBase superuser login, used to read/write records via the REST API # (e.g. migrating content) without loosening the collection API rules -- a # superuser bypasses them. Create the superuser in the dashboard at /_/. -PB_URL=http://:8090 +PB_URL=https://redaktion.elternbeirat-igmh.info PB_ADMIN_EMAIL= PB_ADMIN_PASSWORD= diff --git a/compose.yaml b/compose.yaml index 87576bb..c3c345f 100644 --- a/compose.yaml +++ b/compose.yaml @@ -2,11 +2,11 @@ # only PocketBase's data is a volume, everything else lives inside the images or # in this file. # -# NPM runs outside this stack (the `nginx` container on Unraid) and reaches the web -# app by name over the external Docker network `proxynet` (eb-blazor:8080), so the -# web app publishes no host port. The `ports:` block on PocketBase is TEMPORARY: it -# is the editors' way onto the admin UI until they reach it through an NPM subdomain -# (#9). Unraid setup: docs/unraid-infrastructure.md. +# NPM runs outside this stack (the `nginx` container on Unraid) and reaches both the +# web app (eb-blazor:8080) and the PocketBase admin (eb-pocketbase:8090, for +# redaktion.elternbeirat-igmh.info) by name over the external Docker network +# `proxynet`. No service publishes a host port: NPM is the only way in. Unraid +# setup: docs/unraid-infrastructure.md. # # On Unraid this file is deployed as is by .gitea/workflows/deploy.yml (project # eb-stack), not pasted into the Compose Manager. @@ -39,12 +39,11 @@ services: volumes: # The only state that must survive a restart or redeploy. - /mnt/user/appdata/pocketbase/pb_data:/pb_data - ports: - # TEMPORARY: exposes the admin UI on the LAN (http://:8090/_/) while - # NPM is not in front yet. Replace once the editors reach PocketBase through an - # NPM subdomain (#9): NPM points at eb-pocketbase:8090 over a shared network, so - # this host mapping can go -- until then the admin has no other way in. - - "8090:8090" + networks: + # default: serve the web app. proxynet: be reached by NPM as eb-pocketbase:8090 + # for redaktion.elternbeirat-igmh.info. + - default + - proxynet healthcheck: # The image ships this endpoint; the web app waits for it to pass. test: ["CMD", "wget", "--spider", "-q", "http://localhost:8090/api/health"] diff --git a/docs/deployment.md b/docs/deployment.md index 8f10b78..9f5c5f9 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -103,6 +103,45 @@ Let's Encrypt asks the Strato nameservers directly, so the certificate works as soon as DynDNS has updated, even while public resolvers still cache the old IP. +### Editor subdomain (redaktion.elternbeirat-igmh.info) + +The editors reach the PocketBase admin at +. + +1. **Strato** → Domainverwaltung → **Subdomain anlegen** `redaktion` → its + **DNS** → **CNAME-Record** `elternbeirat-igmh.info`. Like `www`, it follows the + DynDNS IP on its own. +2. `eb-pocketbase` joins `proxynet` (`compose.yaml`), so NPM reaches it by name. +3. **NPM** proxy host: + + | Tab | Field | Value | + |---|---|---| + | Details | Domain Names | `redaktion.elternbeirat-igmh.info` only | + | | Scheme / Forward Hostname / Port | `http` / `eb-pocketbase` / `8090` | + | | Block Common Exploits, Websockets Support | on | + | SSL | SSL Certificate | Request a new SSL Certificate (Let's Encrypt) | + | | Force SSL, HTTP/2 | on | + | Advanced (gear icon) | Custom Nginx Configuration | see below | + + PocketBase has nothing at `/`; this sends the bare subdomain to the admin: + + ```nginx + location = / { + return 302 https://$host/_/; + } + ``` + + The full URL is needed: with a bare path (`return 302 /_/;`) nginx adds its + container port and the redirect lands on `:4443`. + +Pitfalls: no `www.redaktion…` in Domain Names — it has no DNS record, and one +unknown name makes Let's Encrypt refuse the whole certificate. And no Custom +Location for `/`: an empty one without a forward target breaks the subdomain. + +> **The whole PocketBase API is public on this subdomain, not just the admin.** +> That is fine as long as the collection API rules only allow reading; writing is +> for superusers, who bypass the rules (`redaktion.md`). + --- ## Way of working: branches, never directly on main @@ -166,8 +205,8 @@ and there is no stale copy left there that could be started by accident. `compose.yaml` is the **production** base; the workflow deploys it to Unraid as is. It defines all services. `eb-blazor` publishes no host port and joins the external network -`proxynet`, so NPM is the only path to the web app. `eb-pocketbase` still publishes -`8090` for the editors until they reach it through an NPM subdomain (see #9). +`proxynet`, so NPM is the only path to the web app. `eb-pocketbase` joins +`proxynet` too, for the editor subdomain, and publishes no host port either. `eb-pocketbase` keeps its data on the bind mount `/mnt/user/appdata/pocketbase/pb_data`, which only exists on the server. diff --git a/docs/redaktion.md b/docs/redaktion.md index 80d427d..312bcfc 100644 --- a/docs/redaktion.md +++ b/docs/redaktion.md @@ -22,7 +22,7 @@ Das Admin heißt „Redaktion Elternbeirat" und ist unter der PocketBase-Adresse erreichbar: - **Lokal:** (Dev-Stack, siehe `entwicklung.md`). -- **Auf dem Server:** über die NPM-Subdomain (Login von außen — noch offen, #9). +- **Auf dem Server:** , von überall erreichbar. Redakteure sind **Superuser**: jede vertraute Person aus dem Vorstand bekommt einen eigenen Superuser-Zugang (unter *Collections → System → `_superusers`*). diff --git a/docs/unraid-infrastructure.md b/docs/unraid-infrastructure.md index e1b7f85..e54d0bb 100644 --- a/docs/unraid-infrastructure.md +++ b/docs/unraid-infrastructure.md @@ -34,7 +34,7 @@ so the workflow's `docker compose` talks to the Unraid daemon directly. | Container | Network | Container port | Host port | |---|---|---|---| | `eb-blazor` | `eb-internal`, `proxynet` | `8080` | – | -| `eb-pocketbase` | `eb-internal` | `8090` | `8090` | +| `eb-pocketbase` | `eb-internal`, `proxynet` | `8090` | – | | `eb-ddns` | `eb-internal` | – | – | Persistent data: `/mnt/user/appdata/pocketbase/pb_data` → `/pb_data`. @@ -56,13 +56,14 @@ The container is called **`nginx`** and runs on the network `proxynet`. ### Active proxy hosts -Except for the website, destinations use LAN host names (`unraid.server`), +Except for the website stack, destinations use LAN host names (`unraid.server`), resolved by the LAN DNS, never container IPs. That is why they kept working when NPM moved from `bridge` to `proxynet`. | Source | Destination | SSL | |---|---|---| | `elternbeirat-igmh.info`, `www.elternbeirat-igmh.info` | `http://eb-blazor:8080` | Let's Encrypt | +| `redaktion.elternbeirat-igmh.info` | `http://eb-pocketbase:8090` (`/` → `/_/`) | Let's Encrypt | | `gitea.anticarnist.de` | `http://unraid.server:3005` | Let's Encrypt | | `cloud.anticarnist.de` | `https://unraid.server:44304` | Let's Encrypt | | `home.anticarnist.de` | `http://unraid.server:44303` | Let's Encrypt |