Configuration
Docker and Node read environment variables (see docker.env.example). On Cloudflare, MASTER_KEY is a Worker secret and everything else lives in wrangler.jsonc.
Environment variables
| Variable | Default | What it does |
|---|---|---|
MASTER_KEY | Generated into DATA_DIR/master.key for local setups | Encrypts every file and sensitive field. 32 bytes, base64 or hex. Required with a remote database or S3 storage. |
PUBLIC_URL | The address of the request | Used in invite, reset and MCP links. An https:// address also turns on secure cookies. |
PORT | 8080 | Port the server listens on. |
DATA_DIR | ./data | Where the SQLite database, local files and generated key live. |
MAX_UPLOAD_MB | 25 (Cloudflare: 10) | Largest single file accepted. |
DATABASE_URL | SQLite file in DATA_DIR | A libsql:// URL to use Turso instead. |
DATABASE_AUTH_TOKEN | Token for the Turso database. | |
STORAGE_DRIVER | fs | s3 to store files in an S3-compatible bucket. |
S3_ENDPOINT | e.g. https://<account-id>.r2.cloudflarestorage.com or https://s3.us-west-004.backblazeb2.com | |
S3_REGION | auto for R2, the bucket's region for B2 or AWS. | |
S3_BUCKET | Bucket name. | |
S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY | A key limited to that bucket. | |
S3_PREFIX | Optional folder inside the bucket, e.g. kagaz/. |
On Cloudflare
Change these in wrangler.jsonc and run npm run deploy again:
vars.MAX_UPLOAD_MB: largest file in MB (default10).vars.PUBLIC_URL: add this when you use a custom domain.d1_databasesandr2_buckets: names of the database and bucket.triggers.crons: when the daily cleanup runs.
Rotate secrets with npx wrangler secret put MASTER_KEY. Changing the master key makes existing files unreadable, so only do this on an empty vault or right before restoring a backup.
Where data lives
| Setup | Records | Files |
|---|---|---|
| Cloudflare | D1 | R2 |
| Docker (default) | data/kagaz.db | data/files/ |
| Container host | Turso | R2, B2, MinIO or AWS S3 |
Files are always encrypted before they are stored. Document numbers, notes and remembered PDF passwords are encrypted in the database too.
Server commands
For Docker and Node setups. Inside the container, run them with docker compose exec kagaz node dist/node/server/node/cli.js <command>.
| Command | What it does |
|---|---|
reset-link <email> | Prints a one-time password reset link, valid for 24 hours. |
make-admin <email> | Makes someone an admin, for example if the only admin has left. |
users | Lists accounts. |
gen-key | Prints a new random master key. |
On Cloudflare, an admin can make reset links from Settings › Members instead.