Restrict the OAuth2 client to a Pocket ID group and keep email login available. Document how existing users can link their accounts while retaining note ownership.
11 KiB
middleman
The front-end reverse proxy for the colony's public web services — the single ingress that
estuary DNATs HTTP/HTTPS (and Matrix federation on :8448) to. Terminates TLS with wildcard
certificates it issues itself, runs the Pocket ID identity provider with oauth2-proxy in front of
gated vhosts, and runs a librespeed backend and a Paseo relay.
- Source:
shill/containers/middleman/(default.nix,auth.nix,vhosts.nix) - Host: NixOS container on
shill(my.containersephemeral nspawn on thectrsbridge; bind-mounts/mnt/mediaread-only for the static file vhosts) - nixpkgs:
mine
Role
nginx
The reverse proxy enables vts, fancyindex, Brotli, kTLS and a proxy cache. Its dynamic resolver
points at estuary, allowing upstreams named under ams1.int.nul.ie to resolve again at runtime.
All vhosts live in
vhosts.nix. nginx
also waits for colony-psql through systemdAwaitPostgres, avoiding an early-boot DNS stall.
ACME
middleman issues certificates for its own vhosts; it is not a shared CA for other boxes.
ams1.int.nul.ieand its wildcard use a legoexecchallenge that SSHes topdns-file-records@estuary-vm. This is the defaultuseACMEHostcertificate internally.nul.ie,*.nul.ie,*.s3.nul.ieand*.slop.nul.ie(forslop-brokerpreviews) use Cloudflare DNS. ApostRunhook copies renewed material to themailVM and runsmailcow-ssl-reloadthere.- Renewal reloads nginx; the
acmegroup owns the secret files and includes the nginx user.
Pocket ID
Pocket ID (services.pocket-id) is a passkey-only OpenID Connect
provider at id.nul.ie. Apps with OIDC support sign in with it directly (such as the
slop-broker approvals web app); the rest go
through oauth2-proxy.
- Listens on
127.0.0.1:1411behind nginx and keeps its SQLite database in/var/lib/pocket-id(persisted bymy.tmproot). Themiddleman/pocket-id-encryption-keysecret encrypts it. - The first admin is created at
/setup; nginx only allows that page and its API from internal networks (lib.my.c.internalNets). Further users are added from the admin UI.
Declared groups and clients. my.pocket-id (in
auth.nix) declares
user groups and OIDC clients; pocket-id-sync creates and updates them through the API on every
switch.
- It authenticates with the static API key
middleman/pocket-id-api-key. nginx stripsX-API-Keyfrom outside requests, so API keys only work from inside the container. - Clients and groups that aren't declared are left alone, as is group membership: add users to groups in the admin UI.
- A client's secret is an age file shared with the box that runs the app (or a key of an env
file). Generate it with
slop secret generate; after rotating one, restartpocket-id-sync.
SSO
oauth2-proxy signs users in with Pocket ID (client
sso) for vhosts with no sign-in of their own.
ssoServer [ <groups> ]invhosts.nixgates a vhost with nginxauth_request, allowing members of any of the given Pocket ID groups. The gated vhosts currently allowadmins.- Each gated vhost serves oauth2-proxy's
/oauth2/endpoints itself. Its session cookie is host-only, so other.nul.iesites (including*.slop.nul.iepreviews) never receive it. Pocket ID's own session turns signing in to another gated vhost into a redirect. - The
ssoclient's callback URLs are derived from the gated vhosts. - Sessions last a week. Every hour, oauth2-proxy uses a refresh token to check back with Pocket ID without a passkey, and picks up the user's current groups. A disabled user is signed out at the next check; someone removed from a group loses access once their access token expires (an hour at most, Pocket ID's default).
- A location in a gated vhost with its own
add_headerwould drop the refreshed session cookie thatssoServerpasses on. - Its client secret and cookie secret are in the env file
middleman/oauth2-proxy.env. id.nul.ieresolves to the container itself, so oauth2-proxy reaches Pocket ID through the local nginx.
librespeed
The frontend and backend are published as speed.nul.ie and librespeed.ams1.int.nul.ie, both
proxied to localhost:8989.
Paseo relay
paseo-relay (the my.paseo-relay module, package
pkgs/paseo-relay.nix) relays end-to-end encrypted traffic between Paseo daemons and the Paseo
app, in place of Paseo's hosted relay.
- Single node with no Erlang distribution, listening on
127.0.0.1:4000and published aspaseo-relay.nul.ie. It keeps no state, so a restart only drops connections. - The relay can't read or forge messages, so the vhost is open to the world. Its Prometheus
/metricsis not exposed;/healthand/readyare. slop.nul.ieserves Paseo's web app as static files, taken from the same patched Paseo package (our Jujutsu fork) as the daemon, so deploy it together withslop-cannon. Pairing links from our daemon point there, and the app connects through the relay, so nothing frompaseo.shis needed in the browser.
Network assignments
See the consolidated network assignments table (this box: middleman).
The firewall allows http, https and 8448 (Matrix federation). A small nftables SNAT rule
rewrites outbound IPv6 to the container's own address on host0.
Published vhosts
Everything is under *.nul.ie with the public wildcard cert unless noted; defaults applied to
all vhosts are onlySSL, kTLS and HTTP/2. "SSO" = gated behind oauth2-proxy.
| Host | Upstream | Notes |
|---|---|---|
nul.ie (_, default) |
static | landing page (index.html, CV PDF, SSH pubkey); serves Matrix .well-knowns and redirects webfinger/nodeinfo/host-meta → toot.nul.ie, atproto-did → pds.nul.ie; forceSSL (plain HTTP redirects to HTTPS) |
localhost |
— | loopback-only VTS status page at /status (scraped by netdata); plain HTTP |
id.nul.ie |
localhost:1411 |
Pocket ID; /setup only from internal networks; X-API-Key stripped |
netdata-colony.nul.ie |
<host>.ams1.int.nul.ie:19999 |
netdata fan-out over vm, fw, ctr, oci, http, jackflix-ctr, chatterbox-ctr, colony-psql-ctr; SSO |
pass.nul.ie |
vaultwarden-ctr:8080 |
vaultwarden; /notifications/hub proxied with websockets |
matrix.nul.ie |
chatterbox-ctr:8008 |
chatterbox Synapse client + federation; native Pocket ID sign-in; also listens on :8448 as federation default_server; = / redirects to Element; serves Matrix .well-knowns |
element.nul.ie |
static element-web |
Element configured for the nul.ie homeserver |
torrents.nul.ie |
jackflix-ctr:9091 |
Transmission (jackflix); SSO |
jackett.nul.ie |
jackflix-ctr:9117 |
SSO |
radarr.nul.ie |
jackflix-ctr:7878 |
SSO; websockets |
sonarr.nul.ie |
jackflix-ctr:8989 |
SSO; websockets |
gib.nul.ie |
jackflix-ctr:5055 |
Jellyseerr requests |
jackflix.nul.ie |
jackflix-ctr:8096 |
Jellyfin; /socket websockets; / redirects to /web/ |
toot.nul.ie |
toot-ctr:80 |
Mastodon — upstream currently disabled, see toot |
pds.nul.ie |
toot-ctr:3000 |
Bluesky PDS (toot); websockets |
stuff.nul.ie |
jackflix-ctr:3923 |
copyparty |
public.nul.ie (+ alias p.nul.ie) |
static /mnt/media/public |
fancyindex file listing; addSSL so plain HTTP also works |
mc-map.nul.ie |
simpcraft-oci:8100 |
Minecraft map (OCI container on whale2) |
mc-rail.nul.ie |
simpcraft-oci:3876 |
Minecraft railway map (whale2) |
mc-map-kink.nul.ie |
kinkcraft-oci:8100 |
Minecraft map (whale2) |
speed.nul.ie |
localhost:8989 |
librespeed |
librespeed.ams1.int.nul.ie |
localhost:8989 |
librespeed on the internal domain (internal wildcard cert) |
paseo-relay.nul.ie |
localhost:4000 |
Paseo relay; websockets with long timeouts; /metrics blocked |
slop.nul.ie |
static Paseo web app | falls back to index.html; precompressed files served as-is |
approve.slop.nul.ie |
palace.h.nul.ie:8095 |
slop-broker's approvals web app, which handles sign-in itself (Pocket ID) |
md.nul.ie |
object-ctr:3000 |
HedgeDoc; native Pocket ID sign-in; websockets |
pb.nul.ie |
object-ctr:8088 |
wastebin |
photos.nul.ie |
jackflix-ctr:2342 |
PhotoPrism; websockets |
pront.nul.ie |
stream-hi.h.nul.ie:5000 |
OctoPrint on the home network (stream); /webcam/ → :5050; SSO |
hass.nul.ie |
hass-ctr.h.nul.ie:8123 |
Home Assistant (home network); websockets |
hass-john.nul.ie |
john-valorant-tun.ams1.int.nul.ie:8123 |
remote Home Assistant over the point-to-point tunnel; websockets |
minio.nul.ie |
object-ctr:9001 |
MinIO console; /ws websockets |
s3.nul.ie (+ *.s3.nul.ie) |
object-ctr:9000 |
MinIO S3 API (virtual-host style via the *.s3 wildcard cert); /gitea/packages/ has a hack forcing the correct Content-Type for Docker image manifests |
nix-cache.nul.ie |
object-ctr:5000 |
Harmonia Nix binary cache; .narinfo/nar//serve/ paths get immutable Cache-Control/Expires headers |
Notable config files
nixos/boxes/colony/vms/shill/containers/middleman/default.nix— container definition: nginx, ACME, librespeed, Paseo relay, secretsnixos/boxes/colony/vms/shill/containers/middleman/auth.nix— Pocket ID, its declared groups and clients, oauth2-proxynixos/boxes/colony/vms/shill/containers/middleman/vhosts.nix— all virtual hosts, thessoServerhelper, and the.well-knowntreenixos/boxes/colony/vms/shill/containers/middleman/default.html— default vhost landing page