The lab runs a set of self-hosted services including:
- Forgejo for hosting git repos (see also Coding and version control)
- Paperless for storing and characterizing documents
- Vaultwarden for password management
- Grist for databases/spreadsheets (⚠️ setup in progress — see Grist section)
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/servicesunless 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
| Host | WireGuard IP |
|---|---|
| Hetzner VPS | 10.100.0.1 |
| Backend | 10.100.0.2 |
Domain Structure
| Subdomain | Service | Auth |
|---|---|---|
pw.bonhamlab.bio | Vaultwarden | Vaultwarden native (local accounts) |
documents.bonhamlab.bio | Paperless-ngx | Local accounts + 2FA (TOTP) |
code.bonhamlab.bio | Forgejo | Local accounts + 2FA enforced instance-wide |
db.bonhamlab.bio | Grist | OIDC via Forgejo (⚠️ pending free activation key) |
bonhamlab.bio | Astro website | Public (static, no auth) |
wiki.bonhamlab.bio | Quartz wiki | Public (static, no auth) |
Authentication
Each service manages its own authentication independently:
- Vaultwarden: local accounts with master password + optional 2FA (TOTP). Admin panel at
/adminrequires the admin token stored in Vaultwarden. - Forgejo: local accounts with password + 2FA (TOTP, enforced for all users via
GLOBAL_TWO_FACTOR_REQUIREMENT = allinapp.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
/persistvolume (NOT shared Postgres) — keeps all Grist state (home DB + the per-document.gristSQLite 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 isunsafeif gvisor ever fails). - Backup:
/srv/services/grist/persistis 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)
-
Add the key to
.env(e.g.GRIST_ACTIVATION_KEY=...) and reference it in the Gristenvironment:block asGRIST_ACTIVATION: ${GRIST_ACTIVATION_KEY}. -
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 -
cd /srv/docker && docker compose up -d gristand watch logs for OIDC init + no activation complaint. -
Test login round-trip in an incognito window:
db.bonhamlab.bio→ redirects to Forgejo → log in → back to Grist as that user. -
Confirm your Forgejo account’s email matches
dev@bonham.chso your OIDC login lands as the existing admin (Grist matches users by email). -
Once confirmed working, proceed with lab onboarding on Forgejo identities.
Service Management
Backend
All Docker Compose commands run from /srv/docker.
| Action | Command |
|---|---|
| Start all services | cd /srv/docker && docker compose up -d |
| Stop all services | cd /srv/docker && docker compose down |
| Restart a service | cd /srv/docker && docker compose restart <service> |
| Force recreate (picks up env changes) | cd /srv/docker && docker compose down && docker compose up -d |
| View logs | cd /srv/docker && docker compose logs -f <service> |
| Check status | cd /srv/docker && docker compose ps |
| Update images | cd /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).
| Action | Command |
|---|---|
| WireGuard status | sudo wg show |
| Start WireGuard | sudo systemctl start wg-quick@wg0 |
| Stop WireGuard | sudo systemctl stop wg-quick@wg0 |
| Forgejo SSH tunnel status | sudo systemctl status forgejo-tunnel.service |
| Restart Forgejo SSH tunnel | sudo systemctl restart forgejo-tunnel.service |
| Tunnel logs | sudo journalctl -u forgejo-tunnel.service --no-pager -n 50 |
VPS
| Action | Command |
|---|---|
| WireGuard status | sudo wg show |
| Nginx reload (no downtime) | sudo systemctl reload nginx |
| Nginx restart | sudo systemctl restart nginx |
| Nginx config test | sudo nginx -t |
| Nginx error logs | sudo tail -50 /var/log/nginx/error.log |
| SSLH restart | sudo systemctl restart sslh |
| Check port 443 listener | sudo ss -tlnp | grep 443 |
| Check tunnel port | sudo 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
@servicesand@data; sends@servicesto@backupon the HDD raid1 pool. Covers accidental deletion and single-disk failure. DB dumps (pg_dumpof forgejo/paperless/vaultwarden +pg_dumpall --globals-only) are written to/srv/services/postgres/dumpsbefore 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, andgrist/persist, to a local restic repo (/store/backup/restic), thenrsyncover SSH to the Tufts HPC login node (/cluster/tier2/bonhamlab/backup/restic/). The cluster key is hardened withrrsync -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 checkon 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-keyis 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’stuftshpcSSH 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-xattrto 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
-
Add DNS A record →
167.233.140.224in Porkbun -
On VPS:
sudo certbot certonly --nginx -d newservice.bonhamlab.bio -
On VPS: create
/etc/nginx/sites-available/newservice.bonhamlab.bio, symlink tosites-enabledMinimal 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
locationblock:proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_read_timeout 86400; -
On VPS:
sudo nginx -t && sudo systemctl reload nginx -
On backend: add service block to
/srv/docker/compose.yml -
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.
-
On backend: create data directory under
/srv/services/<service>/with correct ownership for the container’s uid. -
On backend:
cd /srv/docker && docker compose up -d newservice -
Verify binding:
sudo ss -tlnp | grep <PORT>— should show10.100.0.2:<PORT> -
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.shif it needs the meteor-strike copy.
Static Sites
Two static sites are hosted directly by Nginx on the VPS (no backend container needed):
| Site | Path on VPS | Repo | Build trigger |
|---|---|---|---|
bonhamlab.bio | /var/www/bonhamlab.bio | Web/bonhamlab.bio | Push to main → Forgejo Actions → rsync |
wiki.bonhamlab.bio | /var/www/wiki.bonhamlab.bio | Internal/ObsidianVault | Push 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:
- Install OpenSUSE, Docker, WireGuard tools; set up the BTRFS storage layout
- Copy the service data (
/srv/services,/store) — preserving ownership/ACLs - Copy
/etc/wireguard/wg0.conf— same private key, same IP10.100.0.2 - Copy the systemd units (
selfhosted.service,forgejo-tunnel.service) - Copy
/etc/wireguard/tunnel_keyand/etc/wireguard/tunnel_key.pub sudo systemctl enable --now wg-quick@wg0sudo systemctl enable --now selfhosted.servicesudo systemctl enable --now forgejo-tunnel.service- Verify:
sudo wg showandcd /srv/docker && docker compose ps
This section describes the general approach; the actual dogen→thoreau migration (Sept–Oct 2026) used
tarwith preserved ownership for the service data and raw Postgres dir, verified by row/file counts. Keep the/srv/servicesvs/storetier 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
| Path | Purpose |
|---|---|
/etc/wireguard/wg0.conf | WireGuard interface config |
/etc/nginx/sites-available/pw.bonhamlab.bio | Vaultwarden Nginx vhost |
/etc/nginx/sites-available/documents.bonhamlab.bio | Paperless Nginx vhost |
/etc/nginx/sites-available/code.bonhamlab.bio | Forgejo Nginx vhost |
/etc/nginx/sites-available/db.bonhamlab.bio | Grist Nginx vhost (WebSocket-enabled) |
/etc/nginx/sites-available/bonhamlab.bio | Main website Nginx vhost |
/etc/nginx/sites-available/wiki.bonhamlab.bio | Wiki Nginx vhost |
/etc/nginx/snippets/ssl-params.conf | Shared TLS settings |
/etc/nginx/snippets/proxy-params.conf | Shared proxy headers |
/etc/default/sslh | SSLH daemon config |
/var/www/bonhamlab.bio/ | Built Astro site files |
/var/www/wiki.bonhamlab.bio/ | Built Quartz wiki files |
Backend (thoreau, OpenSUSE Tumbleweed)
| Path | Purpose |
|---|---|
/etc/wireguard/wg0.conf | WireGuard interface config |
/etc/wireguard/tunnel_key | SSH key for Forgejo reverse tunnel (root, 600) |
/etc/systemd/system/selfhosted.service | Docker Compose systemd unit |
/etc/systemd/system/forgejo-tunnel.service | Forgejo SSH reverse tunnel unit |
/etc/systemd/system/btrbk.{service,timer} | Local nightly backup (btrbk) |
/etc/systemd/system/services-predump.service | Nightly DB dump (runs before btrbk) |
/etc/systemd/system/offsite-backup.{service,timer} | Weekly off-site backup (restic + rsync to Tier 2) |
/srv/docker/compose.yml | Docker Compose stack definition |
/srv/docker/.env | Secrets 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-pass | restic repo password (root, 600; also in Bitwarden cloud) |
/root/.ssh/tier2-backup-key | Dedicated write-only key for off-site rsync to Tufts Tier 2 (root, 600) |
/usr/local/bin/offsite-backup.sh | Weekly off-site backup script |
/usr/local/bin/services-predump.sh | Nightly DB dump script (runs before btrbk) |
Secrets & Keys
Docker Compose Secrets (in /srv/docker/.env)
| Variable | Generated with | Purpose |
|---|---|---|
POSTGRES_PASSWORD | openssl rand -base64 32 | Postgres superuser password |
VAULTWARDEN_DB_PASS | openssl rand -base64 32 | Vaultwarden DB user password |
PAPERLESS_DB_PASS | openssl rand -base64 32 | Paperless DB user password |
FORGEJO_DB_PASS | openssl rand -base64 32 | Forgejo DB user password |
PAPERLESS_SECRET_KEY | openssl rand -base64 48 | Paperless Django secret key |
VAULTWARDEN_ADMIN_TOKEN | vaultwarden hash --profile owasp | Vaultwarden admin panel token (argon2) |
GRIST_SESSION_SECRET | openssl rand -base64 32 | Grist session secret |
GRIST_OIDC_CLIENT_ID / _SECRET | Forgejo OAuth2 app | Grist→Forgejo OIDC |
GRIST_ACTIVATION_KEY | Grist 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 topermitopen="localhost:2222".forgejo-runner/deploy_key(backend) — static-site rsync deploy; authorized on VPScommand="rrsync -wo /var/www/",restrict./root/.ssh/tier2-backup-key(backend) — off-site backup rsync; authorized on the Tufts clustercommand="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.