The lab runs a set of self-hosted services including:

For new users, see Lab services onboarding.

Note (Oct 2026): The backend has migrated from dogen to thoreau (OpenSUSE Tumbleweed, BTRFS). Service data now lives under /srv/services/* (NVMe) and /store/* (HDD raid1), not the old /srv/docker/* layout described in some sections below. Backups (btrbk local + restic off-site to Tufts Tier 2) are now in place. Those sections of this doc predate the migration and are being updated incrementally — treat paths as /srv/services unless noted. See the thoreau-specific docs for storage/backup detail.


Architecture Overview

Two-machine setup connected via an encrypted WireGuard tunnel:

Internet → Hetzner VPS (167.233.140.224)
               │
               ├── SSLH (port 443) → SSH-over-443 → WireGuard → Backend:2222 (Forgejo SSH)
               │                  ↘ HTTPS → Nginx (port 8443)
               │                               │
               │                               ├── pw.bonhamlab.bio        → Vaultwarden
               │                               ├── documents.bonhamlab.bio → Paperless
               │                               ├── code.bonhamlab.bio      → Forgejo
               │                               └── db.bonhamlab.bio        → Grist
               │
               └── WireGuard (port 51820/udp) ──── Backend (10.100.0.2)
                                                        │
                                                        └── Docker Compose
                                                            ├── Vaultwarden    :8080
                                                            ├── Paperless      :8000
                                                            ├── Forgejo        :3000/:2222
                                                            ├── Forgejo runner (CI)
                                                            ├── Grist          :8484
                                                            ├── Postgres       (internal)
                                                            └── Redis          (internal)

Key Design Decisions

  • The VPS is a dumb proxy — it holds no application data. All services run on the backend.
  • Services bind to 10.100.0.2 (the WireGuard interface) only — not reachable from the public internet directly.
  • SSLH multiplexes port 443: SSH handshakes go to Forgejo’s built-in SSH server via the reverse tunnel; TLS goes to Nginx.
  • The backend is portable — migrating to new hardware means copying the service data and /etc/wireguard/wg0.conf. The VPS config requires zero changes.
  • The backend is thoreau as of Oct 2026 (was dogen).

WireGuard Addressing

HostWireGuard IP
Hetzner VPS10.100.0.1
Backend10.100.0.2

Domain Structure

SubdomainServiceAuth
pw.bonhamlab.bioVaultwardenVaultwarden native (local accounts)
documents.bonhamlab.bioPaperless-ngxLocal accounts + 2FA (TOTP)
code.bonhamlab.bioForgejoLocal accounts + 2FA enforced instance-wide
db.bonhamlab.bioGristOIDC via Forgejo (⚠️ pending free activation key)
bonhamlab.bioAstro websitePublic (static, no auth)
wiki.bonhamlab.bioQuartz wikiPublic (static, no auth)

Authentication

Each service manages its own authentication independently:

  • Vaultwarden: local accounts with master password + optional 2FA (TOTP). Admin panel at /admin requires the admin token stored in Vaultwarden.
  • Forgejo: local accounts with password + 2FA (TOTP, enforced for all users via GLOBAL_TWO_FACTOR_REQUIREMENT = all in app.ini). GitHub and GitLab OAuth2 also available for collaborators who prefer it. Also acts as the OIDC provider for Grist.
  • Paperless: local accounts with password + 2FA (TOTP, required by policy but not enforced at the app level — enforced during onboarding).
  • Grist: OIDC, delegating to Forgejo as the identity provider (users log in with their Forgejo accounts). ⚠️ Not yet live — see Grist section.

There is no shared SSO layer (Grist→Forgejo OIDC is the first step toward one). Credentials for each service are stored in Vaultwarden.


Grist (setup in progress)

Self-hosted Grist at db.bonhamlab.bio — databases/spreadsheets tool. Status as of Oct 20 2026: running, but auth not finalized — waiting on Grist free activation key (a few business days) before OIDC can be enabled.

Decisions made

  • Image: gristlabs/grist:latest (full edition, toggles to community until activated).
  • Home DB: SQLite in the /persist volume (NOT shared Postgres) — keeps all Grist state (home DB + the per-document .grist SQLite files) in one directory, so one filesystem snapshot captures everything consistently.
  • Auth: OIDC delegating to Forgejo. Requires Grist’s free activation key (free for individuals / orgs under $1M annual income). A 30-day full-edition trial does NOT enable self-hosted OIDC; the permanent free key is expected to. Key requested; awaiting delivery.
  • Redis: uses the existing Redis at DB index 1 (redis://redis:6379/1) — Paperless uses index 0.
  • Sandbox: GRIST_SANDBOX_FLAVOR=gvisor (started cleanly; fallback is unsafe if gvisor ever fails).
  • Backup: /srv/services/grist/persist is under @services, so btrbk covers it automatically. It has also been added to the restic off-site backup sources.

Current running config

Data dir: /srv/services/grist/persist (owned 1000:1000). Port 8484 bound to 10.100.0.2. nginx vhost db.bonhamlab.bio includes WebSocket upgrade headers (Grist is real-time) and client_max_body_size 256M.

.env additions: GRIST_SESSION_SECRET, GRIST_DEFAULT_EMAIL=dev@bonham.ch, GRIST_OIDC_CLIENT_ID, GRIST_OIDC_CLIENT_SECRET (from the Forgejo OAuth app).

Forgejo OAuth2 app registered: redirect URI https://db.bonhamlab.bio/oauth2/callback.

Interim state

Running with getgrist.com cloud auth (temporary). Lab onboarding is on hold until OIDC is live, to avoid creating getgrist.com-based user records that would then need migrating to Forgejo identities.

Resume steps (when the free activation key arrives)

  1. Add the key to .env (e.g. GRIST_ACTIVATION_KEY=...) and reference it in the Grist environment: block as GRIST_ACTIVATION: ${GRIST_ACTIVATION_KEY}.

  2. Add the OIDC env block to the Grist service in /srv/docker/compose.yml:

    GRIST_FORCE_LOGIN: "true"GRIST_OIDC_IDP_ISSUER: https://code.bonhamlab.bioGRIST_OIDC_IDP_CLIENT_ID: ${GRIST_OIDC_CLIENT_ID}GRIST_OIDC_IDP_CLIENT_SECRET: ${GRIST_OIDC_CLIENT_SECRET}GRIST_OIDC_IDP_SCOPES: "openid email profile"GRIST_OIDC_IDP_SKIP_END_SESSION_ENDPOINT: "true"   # Forgejo has no end_session_endpoint
  3. cd /srv/docker && docker compose up -d grist and watch logs for OIDC init + no activation complaint.

  4. Test login round-trip in an incognito window: db.bonhamlab.bio → redirects to Forgejo → log in → back to Grist as that user.

  5. Confirm your Forgejo account’s email matches dev@bonham.ch so your OIDC login lands as the existing admin (Grist matches users by email).

  6. Once confirmed working, proceed with lab onboarding on Forgejo identities.


Service Management

Backend

All Docker Compose commands run from /srv/docker.

ActionCommand
Start all servicescd /srv/docker && docker compose up -d
Stop all servicescd /srv/docker && docker compose down
Restart a servicecd /srv/docker && docker compose restart <service>
Force recreate (picks up env changes)cd /srv/docker && docker compose down && docker compose up -d
View logscd /srv/docker && docker compose logs -f <service>
Check statuscd /srv/docker && docker compose ps
Update imagescd /srv/docker && docker compose pull && docker compose up -d

Service names: postgres, redis, vaultwarden, paperless, forgejo, forgejo-runner, grist, hedgedoc

The stack is managed by the selfhosted.service systemd unit (starts after docker.service and wg-quick@wg0.service, with Restart=on-failure).

ActionCommand
WireGuard statussudo wg show
Start WireGuardsudo systemctl start wg-quick@wg0
Stop WireGuardsudo systemctl stop wg-quick@wg0
Forgejo SSH tunnel statussudo systemctl status forgejo-tunnel.service
Restart Forgejo SSH tunnelsudo systemctl restart forgejo-tunnel.service
Tunnel logssudo journalctl -u forgejo-tunnel.service --no-pager -n 50

VPS

ActionCommand
WireGuard statussudo wg show
Nginx reload (no downtime)sudo systemctl reload nginx
Nginx restartsudo systemctl restart nginx
Nginx config testsudo nginx -t
Nginx error logssudo tail -50 /var/log/nginx/error.log
SSLH restartsudo systemctl restart sslh
Check port 443 listenersudo ss -tlnp | grep 443
Check tunnel portsudo ss -tlnp | grep 2222

Admin Operations

Reset a user’s Forgejo password (when locked out):

docker exec -it --user 1000 selfhosted-forgejo-1 forgejo admin user change-password --username <username> --password '<newpassword>'

Reset a user’s Paperless password:

docker exec -it selfhosted-paperless-1 python3 manage.py changepassword <username>

Reset Forgejo 2FA (if user loses their device): Admin panel → Site Administration → User Accounts → edit user → Reset two-factor authentication

Vaultwarden admin panel: https://pw.bonhamlab.bio/admin — requires the admin token stored in Vaultwarden.


Backups

Added Oct 2026 after the thoreau migration. Three layers, different failure domains:

  • btrbk (local, nightly 03:00): snapshots @services and @data; sends @services to @backup on the HDD raid1 pool. Covers accidental deletion and single-disk failure. DB dumps (pg_dump of forgejo/paperless/vaultwarden + pg_dumpall --globals-only) are written to /srv/services/postgres/dumps before each snapshot so snapshots carry restore-ready SQL.
  • restic → Tufts Tier 2 (off-site, weekly Sun 04:00): encrypted, deduplicated backup of @data, @media, the DB dumps, and grist/persist, to a local restic repo (/store/backup/restic), then rsync over SSH to the Tufts HPC login node (/cluster/tier2/bonhamlab/backup/restic/). The cluster key is hardened with rrsync -wo (write-only, confined to the backup dir). Covers whole-site loss (fire/theft). Repo password is in Bitwarden cloud (off-box) — unrecoverable if lost.
  • snapper (OS root): OpenSUSE’s default root snapshots + GRUB rollback, for OS-level recovery.

Retention: @services 7d/5w/3m; @data 7d/5w; restic keeps last 3 weekly.

Restore-test verified (Nov 6 2026) ✓

The off-site DR path was tested end to end and passed:

  • restic check on the local repo — no errors (repo structure + password sound).
  • Opened the Tier 2 repo directly over SFTP (restic -r sftp:... via interactive cluster access) and listed all snapshots — proves the off-site copy is a valid, openable restic repository, not just bytes on disk.
  • Restored a real file (forgejo.sql, 1.5 MB) from the Tier 2 Nov 1 snapshot to a scratch dir — recovered intact, valid Postgres dump.

Notes for a real disaster restore:

  • The automated tier2-backup-key is write-only (rrsync -wo) and cannot pull data back. Retrieval uses interactive cluster credentials (ssh tuftshpc), which is realistic — in a disaster you log in as yourself. The restore command is: sudo RESTIC_PASSWORD_FILE=/root/.restic-offsite-pass restic -o sftp.command="ssh -i /home/kevin/.ssh/tuftshpc-key kbonha01@login-prod.pax.tufts.edu -s sftp" -r sftp:kbonha01@login-prod.pax.tufts.edu:/cluster/tier2/bonhamlab/backup/restic restore <snap> --target <dir>
  • restic over SFTP as root needs the explicit sftp.command (root can’t resolve kevin’s tuftshpc SSH alias). The repo password is in Bitwarden cloud.
  • Restores emit a benign xattr ... security.selinux: permission denied (“Fatal: 1 error”) because thoreau uses AppArmor, not SELinux — file contents restore fine. Use --no-xattr to silence it.

Still not covered: @media has no backup beyond the off-site restic copy + app-level trash (Immich/Paperless) — no separate local snapshot (deliberate: high-churn/bulky).


Adding a New Service

  1. Add DNS A record → 167.233.140.224 in Porkbun

  2. On VPS: sudo certbot certonly --nginx -d newservice.bonhamlab.bio

  3. On VPS: create /etc/nginx/sites-available/newservice.bonhamlab.bio, symlink to sites-enabled

    Minimal template (no auth gate — each service handles its own auth):

    server {
        listen 8443 ssl;
        http2 on;
        server_name newservice.bonhamlab.bio;
     
        ssl_certificate     /etc/letsencrypt/live/newservice.bonhamlab.bio/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/newservice.bonhamlab.bio/privkey.pem;
        include /etc/nginx/snippets/ssl-params.conf;
     
        client_max_body_size 100M;
     
        location / {
            proxy_pass http://10.100.0.2:<PORT>;
            include /etc/nginx/snippets/proxy-params.conf;
        }
    }

    For real-time apps (Grist, HedgeDoc) add WebSocket headers in the location block:

    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_read_timeout 86400;
  4. On VPS: sudo nginx -t && sudo systemctl reload nginx

  5. On backend: add service block to /srv/docker/compose.yml

  6. On backend: if Postgres needed, create DB manually (init script only runs on first Postgres boot):

    docker exec -it selfhosted-postgres-1 psql -U postgres -c "CREATE USER newservice WITH PASSWORD 'password';"
    docker exec -it selfhosted-postgres-1 psql -U postgres -c "CREATE DATABASE newservice OWNER newservice;"

    Also add to the postgres initdb script for future fresh installs.

  7. On backend: create data directory under /srv/services/<service>/ with correct ownership for the container’s uid.

  8. On backend: cd /srv/docker && docker compose up -d newservice

  9. Verify binding: sudo ss -tlnp | grep <PORT> — should show 10.100.0.2:<PORT>

  10. If the service holds irreplaceable data, confirm its data dir is under @services (btrbk covers it) and add it to the restic off-site sources in /usr/local/bin/offsite-backup.sh if it needs the meteor-strike copy.


Static Sites

Two static sites are hosted directly by Nginx on the VPS (no backend container needed):

SitePath on VPSRepoBuild trigger
bonhamlab.bio/var/www/bonhamlab.bioWeb/bonhamlab.bioPush to main → Forgejo Actions → rsync
wiki.bonhamlab.bio/var/www/wiki.bonhamlab.bioInternal/ObsidianVaultPush to main → Forgejo Actions → clone Web/wiki-backend → build Quartz → rsync

Deploy SSH key is stored at /srv/docker/forgejo-runner/deploy_key on the backend (used by the runner to rsync to the VPS). The corresponding public key is in /home/kevin/.ssh/authorized_keys on the VPS, restricted via rrsync -wo /var/www/.


Migration to New Hardware

The VPS requires zero changes. On the new backend machine:

  1. Install OpenSUSE, Docker, WireGuard tools; set up the BTRFS storage layout
  2. Copy the service data (/srv/services, /store) — preserving ownership/ACLs
  3. Copy /etc/wireguard/wg0.conf — same private key, same IP 10.100.0.2
  4. Copy the systemd units (selfhosted.service, forgejo-tunnel.service)
  5. Copy /etc/wireguard/tunnel_key and /etc/wireguard/tunnel_key.pub
  6. sudo systemctl enable --now wg-quick@wg0
  7. sudo systemctl enable --now selfhosted.service
  8. sudo systemctl enable --now forgejo-tunnel.service
  9. Verify: sudo wg show and cd /srv/docker && docker compose ps

This section describes the general approach; the actual dogen→thoreau migration (Sept–Oct 2026) used tar with preserved ownership for the service data and raw Postgres dir, verified by row/file counts. Keep the /srv/services vs /store tier split in mind for any future move.


Files & Paths

⚠️ The detailed VPS and backend path tables below predate the thoreau migration in places (old /srv/docker/* data paths are now under /srv/services/*). The VPS paths are still accurate. Backend service-data paths should be read as /srv/services/<service>/.... This table is slated for a fuller rewrite.

Hetzner VPS

PathPurpose
/etc/wireguard/wg0.confWireGuard interface config
/etc/nginx/sites-available/pw.bonhamlab.bioVaultwarden Nginx vhost
/etc/nginx/sites-available/documents.bonhamlab.bioPaperless Nginx vhost
/etc/nginx/sites-available/code.bonhamlab.bioForgejo Nginx vhost
/etc/nginx/sites-available/db.bonhamlab.bioGrist Nginx vhost (WebSocket-enabled)
/etc/nginx/sites-available/bonhamlab.bioMain website Nginx vhost
/etc/nginx/sites-available/wiki.bonhamlab.bioWiki Nginx vhost
/etc/nginx/snippets/ssl-params.confShared TLS settings
/etc/nginx/snippets/proxy-params.confShared proxy headers
/etc/default/sslhSSLH daemon config
/var/www/bonhamlab.bio/Built Astro site files
/var/www/wiki.bonhamlab.bio/Built Quartz wiki files

Backend (thoreau, OpenSUSE Tumbleweed)

PathPurpose
/etc/wireguard/wg0.confWireGuard interface config
/etc/wireguard/tunnel_keySSH key for Forgejo reverse tunnel (root, 600)
/etc/systemd/system/selfhosted.serviceDocker Compose systemd unit
/etc/systemd/system/forgejo-tunnel.serviceForgejo SSH reverse tunnel unit
/etc/systemd/system/btrbk.{service,timer}Local nightly backup (btrbk)
/etc/systemd/system/services-predump.serviceNightly DB dump (runs before btrbk)
/etc/systemd/system/offsite-backup.{service,timer}Weekly off-site backup (restic + rsync to Tier 2)
/srv/docker/compose.ymlDocker Compose stack definition
/srv/docker/.envSecrets and environment (kevin:kevin, 600)
/srv/services/Service data volumes (NVMe): postgres, redis, vaultwarden, paperless (data), forgejo, forgejo-runner, grist/persist
/store/data/Lab data (HDD raid1)
/store/media/Paperless media, Immich (HDD raid1)
/store/backup/btrbk received snapshots + restic repo (HDD raid1)
/store/registry/Container registry (HDD raid1)
/mnt/btrbk/{srv,store}btrbk-only mounts of the fs roots (subvolid=5); ignore in normal use
/root/.restic-offsite-passrestic repo password (root, 600; also in Bitwarden cloud)
/root/.ssh/tier2-backup-keyDedicated write-only key for off-site rsync to Tufts Tier 2 (root, 600)
/usr/local/bin/offsite-backup.shWeekly off-site backup script
/usr/local/bin/services-predump.shNightly DB dump script (runs before btrbk)

Secrets & Keys

Docker Compose Secrets (in /srv/docker/.env)

VariableGenerated withPurpose
POSTGRES_PASSWORDopenssl rand -base64 32Postgres superuser password
VAULTWARDEN_DB_PASSopenssl rand -base64 32Vaultwarden DB user password
PAPERLESS_DB_PASSopenssl rand -base64 32Paperless DB user password
FORGEJO_DB_PASSopenssl rand -base64 32Forgejo DB user password
PAPERLESS_SECRET_KEYopenssl rand -base64 48Paperless Django secret key
VAULTWARDEN_ADMIN_TOKENvaultwarden hash --profile owaspVaultwarden admin panel token (argon2)
GRIST_SESSION_SECRETopenssl rand -base64 32Grist session secret
GRIST_OIDC_CLIENT_ID / _SECRETForgejo OAuth2 appGrist→Forgejo OIDC
GRIST_ACTIVATION_KEYGrist free activation (pending)Unlocks Grist full-edition OIDC

Raw secrets (plaintext, pre-hash where applicable) are stored in Vaultwarden. The restic off-site repo password is in Bitwarden cloud (deliberately off-box, so it survives loss of thoreau).

Key SSH keys

  • /etc/wireguard/tunnel_key (backend) — Forgejo reverse tunnel; authorized on VPS restricted to permitopen="localhost:2222".
  • forgejo-runner/deploy_key (backend) — static-site rsync deploy; authorized on VPS command="rrsync -wo /var/www/",restrict.
  • /root/.ssh/tier2-backup-key (backend) — off-site backup rsync; authorized on the Tufts cluster command="rrsync -wo /cluster/tier2/bonhamlab/backup",restrict. Write-only — cannot pull data back; disaster restore uses interactive cluster credentials (see Backups → Restore-test).

WireGuard Keys

Generated per machine (wg genkey | tee private.key | wg pubkey > public.key). Each side’s public key goes in the other’s [Peer]. The thoreau backend reuses dogen’s original keypair/identity, so the VPS [Peer] needed no change at migration.