Self Host Wizard Documentación

Archivos (drive)

Archivos en una caja Self Host Wizard: la pieza drive, en drive.<dominio de apps>, ingreso forward, límite de memoria 64 MB.

De un vistazo

DatoValor
Direcciónhttps://drive.<dominio de apps>
Ingresoforward: Caddy le pregunta a Authelia antes de que la app vea el pedido (forward auth)
Límite de memoria64 MB (ram_mb: pico medido × 1,3)
Base de datosninguna compartida: guarda sus datos en THX_DATA
Necesitalldap, authelia, collabora
La necesitannada
Contenedoresdrive
Imagen: drivegcr.io/distroless/static-debian13:nonroot@sha256:8ce6dd87e9823c5b48dcfb2c8604714ccb351ce59607327bcc4957448da279b5
Abierto sin ingresar/dav /dav/*
Licencia (según el README)varias; mirá las notas de abajo
Proyecto original (según el README)https://drive.<apps_domain>

Cómo activarla

thx enable agrega drive y todo lo que necesita al estado de la caja; después thx apply la instala. Las apps se aplican recién cuando site_domain está definido.

sudo thx enable drive
sudo thx apply

Notas técnicas (pieces/drive/README.md)

Las notas técnicas de cada pieza están en inglés, tal como están en el repositorio.

Served at https://drive.<apps_domain>. Our own server, cmd/thx-drive (package internal/drive), built on golang.org/x/net/webdav (BSD-3-Clause) and github.com/go-ldap/ldap/v3 (MIT).

Spaces

PathWhoQuota
/methe user aloneDRIVE_USER_QUOTA_MB (3072)
/org/<org>members of LLDAP group org-<org>DRIVE_SPACE_QUOTA_MB (10240) each
/team/<org>/<team>members of team-<org>-<team>same

A user sees only the spaces of their own groups; everything else is 404, never 403, so names of other companies' folders do not leak. Org names may contain hyphens, so a team group is split at the longest org in THX_ORGS (or in the user's own org-* groups) that prefixes it. Space roots cannot be deleted or renamed. A write that would pass the quota gets 507 and leaves no partial file.

On disk (THX_DATA): users/<uid>/, orgs/<org>/, teams/<org>/<team>/, files mode 0600, owned by uid 65532.

Three ways in

  • Browser — /, /api/*, /web/dav/*, behind Caddy's forward_auth. Identity is Remote-User/Remote-Groups, believed only from the container's default gateway (the host end of the piece network thx-drive, where Caddy's connections arrive). Any other container on that network that sends those headers gets 403 — test.sh proves it.
  • WebDAV clients (Windows/macOS/Linux file managers, phones, rclone) — https://drive.<apps_domain>/dav/ with LLDAP username + password (HTTP Basic, checked by an LLDAP bind; successful logins cached 60 s; 5 wrong passwords lock that user's WebDAV login for 5 minutes, 429). Remote-* headers are ignored here. Caddy must proxy /dav* without forward_auth.
  • The document editor (the collabora piece) — /wopi/files/*, the WOPI host. Only over the piece network, at http://drive:8080 (the editor joins thx-drive because drive depends on it); a call through Caddy comes from the gateway and gets 403. Every call carries a token drive signed (HMAC-SHA256 with the wopi_key secret) for one user and one file, valid 1 hour; without a valid one, 401. On each call the user's groups are read live from LLDAP (60 s cache), so a user removed from a company or put in suspended is refused within a minute even with a token in hand; the file must still be in one of their spaces, else 404.

thx writes the Caddy site from piece.toml: [forward] public_paths = ["/dav", "/dav/*"] are proxied without forward_auth (Caddy strips client-sent Remote-* there), everything else goes through forward_auth.

The web UI (internal/drive/ui, no framework, embedded in the binary): spaces with usage, breadcrumbs, upload (button or drag and drop, with progress), download, new folder, rename, delete, and the WebDAV address to connect a client. Office files (.docx .doc .odt .rtf .xlsx .xls .ods .csv .pptx .ppt .odp) open in the editor at /office?path=…, inside drive's own page, and the New menu makes a document, spreadsheet or presentation (an empty file the editor fills on first save) besides a folder. Other files open with Content-Security-Policy: sandbox and nosniff, so an uploaded HTML file cannot run script on the drive origin.

Office documents (WOPI)

/office asks POST /api/office/open {"path"} (JSON only, so no other site can post it from a form) for the editor URL and a token, posts the token into an iframe on https://docs.<apps_domain>, and renews it when the editor asks (App_TokenExpiring). Its CSP allows framing and form posts to the editor's origin only. drive implements CheckFileInfo, GetFile, PutFile, Lock, Unlock, RefreshLock, GetLock and PutRelativeFile (Save As). All users opening one file get the same WOPI file id, so they share one editing session (co-editing).

PutFile is written to THX_DATA/.wopi-tmp, checked against the quota as it streams, and renamed over the file: over quota is 507 and the file stays as it was; a save based on an older version than the one on disk (someone changed it over WebDAV meanwhile) is 409 with COOLStatusCode 1010, and the editor asks the user what to keep.

Environment (compose.yaml): WOPI_KEY (THX_SECRET_WOPI_KEY, 32 bytes hex), WOPI_URL (how the editor reaches drive), PUBLIC_URL (drive's own origin, for the editor's postMessage), DOCS_URL (the editor's public origin), DOCS_INTERNAL_URL (where drive reads the editor's /hosting/discovery; read on first use and every 10 minutes, never at start, so drive starts and serves files while the editor is down; /office then says the editor is not available, 503).

The WebDAV password path now refuses users in the suspended group (403) as the forward-auth path already did through Authelia; before, a suspended user's password still worked on /dav.

Image and binary

gcr.io/distroless/static-debian13:nonroot, pinned by multi-arch index digest; it contributes CA roots and nothing else. The binary is bind-mounted read-only from /usr/local/lib/thx/thx-drive (thx installs it; see the lane report for the build lines). The container starts as root with only CHOWN, DAC_OVERRIDE, SETUID and SETGID, gives /data to 65532 if needed, and drops to 65532 for good before serving. Root filesystem read-only, no-new-privileges.

Measured (dev PC, ./test.sh)

43 checks: WebDAV with LLDAP passwords (upload/download byte for byte, MOVE, MKCOL, DELETE), web UI endpoints with forwarded identity, isolation between users, teams and companies (404), .. traversal, quotas (user and space, 507, no partial file), lockout after 5 wrong passwords, Basic ignored on UI paths and Remote-User ignored on /dav, a spoofed Remote-User from another container on the network refused (403), everything on disk owned by 65532. Load: a 40 MB file up and down and a 300-file folder listed via WebDAV and the UI.

The WOPI host is proven against the real editor by pieces/collabora/test.sh, and in go test ./internal/drive (wopi_test.go: tokens, refusals, quota, version conflicts, locks, Save As, suspended users).

RAM: the Go heap stays near 8 MiB (transfers stream), but socket buffers and dirty pages of a large upload count against the cgroup too, and they grow to whatever the limit allows. The test passes at 16m and fails at 11m (connection dropped mid 40 MB upload). At 21m the working set (anon + kernel + dirty) measured 9, 10, 18 and 21 MiB over runs, and one run on 2026-11-25 was OOM-killed mid upload: the dirty pages of an upload are charged to the container's cgroup, so the peak tracks disk writeback speed, not the program. Real uploads are larger than the test's 40 MB, so ram_mb = mem_limit = 64 (lead decision, 2026-11-25) rather than peak × 1.3, with GOMEMLIMIT=12MiB keeping the Go heap small.

Known gaps

  • No share links (optional in the brief); sharing is by space membership.
  • Uploads are written in place: a client that disconnects mid-upload leaves a truncated file (quota refusals do clean up). A temp-file-and-rename PUT would fix it.
  • Quota usage is measured by walking a space the first time it is touched after start, then tracked; files changed behind the server's back (restore) are counted at the next restart.
  • Users removed from a group keep WebDAV access for up to 60 s (login cache).
  • WebDAV locks are in memory; a restart drops them (clients re-lock). WOPI locks too, and the two do not see each other: a WebDAV write to a file open in the editor is caught by the version check at the editor's next save (409, the user chooses), not prevented.
  • Renaming or moving a file that is open in the editor makes the editor's next save fail (the WOPI id is the path); the user can Save As.
  • drive depends on collabora, so installing drive brings the editor (~1.1 GB RAM). See the lane report for the owner decision.

Los datos de esta página salen de estos archivos del repositorio selfhostwizard:

  • pieces/drive/piece.toml
  • pieces/drive/compose.yaml
  • pieces/drive/README.md
  • internal/piece/piece.go

Esta página se genera desde el código al compilar el sitio, así que cambia cuando cambia el código.