From 7c28288fd25b2f53efed044f9b20afa89ded2a52 Mon Sep 17 00:00:00 2001 From: Jasper Mayone Date: Thu, 12 Nov 2026 20:35:29 -0500 Subject: [PATCH 1/2] feat(selvage): pass the admin web ui paths through nginx on twill --- README.md | 2 +- hosts/twill/configuration.nix | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0a15ab8..8f196ee 100644 --- a/README.md +++ b/README.md @@ -317,7 +317,7 @@ To test top-ups on staging, add a sandbox `MERCURY_WRITE_TOKEN` with batting's p | Item | Value | |---|---| -| URL | `https://selvage.patchworklabs.org` (router `selvage-twill` in `edge-alastor`). nginx on twill passes only `POST /slack/*` and `GET /up`. Every other path is 404. | +| URL | `https://selvage.patchworklabs.org` (router `selvage-twill` in `edge-alastor`). nginx on twill passes `POST /slack/*`, `GET /up`, and the moderator web UI under `/admin`, `/auth/` and `/assets/`. The app checks the weave role on every `/admin` request. Every other path is 404. | | Units | `selvage-web` (`./bin/rails db:migrate` in a one-off container, then `./bin/rails server` on `127.0.0.1:3009`) and `selvage-worker` (`bundle exec good_job start`, on the web container's image) | | Image | `ghcr.io/patchworklabsorg/selvage:main` (option `image`). Pin it to `:` for a known build. | | Databases | `patchwork_central` on skein and `patchwork_central_restricted` on seam. Role and schema `selvage` in each. | diff --git a/hosts/twill/configuration.nix b/hosts/twill/configuration.nix index e6473d7..f91e350 100644 --- a/hosts/twill/configuration.nix +++ b/hosts/twill/configuration.nix @@ -67,7 +67,10 @@ } ]; # Slack calls the three request URLs under /slack/ (POST only), and - # the health check is GET /up. Nothing else of the app is public. + # the health check is GET /up. The moderator web UI lives under + # /admin, its weave login under /auth, and its assets under /assets. + # The app checks the weave role on every /admin request. Nothing else + # of the app is public. locations."/slack/" = { proxyPass = upstream; extraConfig = '' @@ -75,6 +78,9 @@ ''; }; locations."= /up".proxyPass = upstream; + locations."/admin".proxyPass = upstream; + locations."/auth/".proxyPass = upstream; + locations."/assets/".proxyPass = upstream; locations."/".return = "404"; }; }; From 3887d00c41dbfb6c8169ffa25d3c2bc0da4244bb Mon Sep 17 00:00:00 2001 From: Jasper Mayone Date: Thu, 12 Nov 2026 20:38:53 -0500 Subject: [PATCH 2/2] fix(selvage): exact admin paths, a cable location, and current comments --- README.md | 2 +- hosts/alastor/edge.nix | 3 ++- hosts/twill/configuration.nix | 21 +++++++++++++++++++-- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8f196ee..466b2b9 100644 --- a/README.md +++ b/README.md @@ -317,7 +317,7 @@ To test top-ups on staging, add a sandbox `MERCURY_WRITE_TOKEN` with batting's p | Item | Value | |---|---| -| URL | `https://selvage.patchworklabs.org` (router `selvage-twill` in `edge-alastor`). nginx on twill passes `POST /slack/*`, `GET /up`, and the moderator web UI under `/admin`, `/auth/` and `/assets/`. The app checks the weave role on every `/admin` request. Every other path is 404. | +| URL | `https://selvage.patchworklabs.org` (router `selvage-twill` in `edge-alastor`). nginx on twill passes `POST /slack/*`, `GET /up`, and the moderator web UI under `/admin`, `/auth/`, `/assets/` and `/cable`. The app checks the weave role on every `/admin` request. Every other path is 404. | | Units | `selvage-web` (`./bin/rails db:migrate` in a one-off container, then `./bin/rails server` on `127.0.0.1:3009`) and `selvage-worker` (`bundle exec good_job start`, on the web container's image) | | Image | `ghcr.io/patchworklabsorg/selvage:main` (option `image`). Pin it to `:` for a known build. | | Databases | `patchwork_central` on skein and `patchwork_central_restricted` on seam. Role and schema `selvage` in each. | diff --git a/hosts/alastor/edge.nix b/hosts/alastor/edge.nix index d47290c..2538f97 100644 --- a/hosts/alastor/edge.nix +++ b/hosts/alastor/edge.nix @@ -52,7 +52,8 @@ let hosts = [ "stash-staging.patchworklabs.org" ]; }; # Selvage on twill (../twill/selvage.nix): production only. nginx on - # twill passes only /slack/ and /up. + # twill passes /slack/, /up, and the admin web UI (/admin, /auth/, + # /assets/, /cable). selvage-twill = { backend = "twill"; hosts = [ "selvage.patchworklabs.org" ]; diff --git a/hosts/twill/configuration.nix b/hosts/twill/configuration.nix index f91e350..e77be32 100644 --- a/hosts/twill/configuration.nix +++ b/hosts/twill/configuration.nix @@ -68,7 +68,8 @@ ]; # Slack calls the three request URLs under /slack/ (POST only), and # the health check is GET /up. The moderator web UI lives under - # /admin, its weave login under /auth, and its assets under /assets. + # /admin, its weave login under /auth, its assets under /assets, and its + # live updates on /cable. # The app checks the weave role on every /admin request. Nothing else # of the app is public. locations."/slack/" = { @@ -78,9 +79,25 @@ ''; }; locations."= /up".proxyPass = upstream; - locations."/admin".proxyPass = upstream; + locations."= /admin".proxyPass = upstream; + locations."/admin/".proxyPass = upstream; locations."/auth/".proxyPass = upstream; locations."/assets/".proxyPass = upstream; + # Turbo Streams for live updates in the admin UI (Action Cable). + # proxyWebsockets sets proxy_set_header in this location, and nginx then + # drops the http-level ones here, so set them again. Action Cable checks + # the Origin against the Host. + locations."= /cable" = { + proxyPass = upstream; + proxyWebsockets = true; + extraConfig = '' + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto; + proxy_set_header X-Forwarded-Host $host; + ''; + }; locations."/".return = "404"; }; };