Install and hosting
Every setup needs a MASTER_KEY: a random secret that encrypts every stored file. Make one now and keep a copy somewhere other than the server, such as a password manager or a printed sheet with your recovery codes.
openssl rand -base64 32
Without MASTER_KEY, stored files can't be decrypted. A recent backup plus its passphrase is the only other way back.
Cloudflare (free plan)
The recommended setup. Kagaz runs as a Cloudflare Worker, keeps records in a D1 database and encrypted files in an R2 bucket. A family-sized vault fits in the free plan.
With the Deploy to Cloudflare button
The button in the README copies the repository to your GitHub account, creates the D1 database and R2 bucket, asks for MASTER_KEY, then builds and deploys. Your vault is then live at https://kagaz.<your-subdomain>.workers.dev.
The button only works while the repository is public. If it doesn't work for you, use the manual steps below.
Manually, with Wrangler
- Install Node.js 22 or newer, then get the code:
git clone https://github.com/bnap00/kagaz cd kagaz npm install - Sign in to Cloudflare and store the master key as a secret:
npx wrangler login npx wrangler secret put MASTER_KEY - Build and deploy. The first deploy creates the D1 database and the R2 bucket:
npm run build npm run deploy - Open the address Wrangler prints and create your family vault.
R2 has to be enabled once on your Cloudflare account (R2 Object Storage in the dashboard). It has a free tier, but Cloudflare may ask for a payment method.
What gets created
| Resource | Binding | Holds |
|---|---|---|
Worker kagaz | The API and the web app | |
D1 database kagaz | DB | Records. Tables are created on the first request. |
R2 bucket kagaz-files | FILES | Encrypted files |
| Daily cron trigger | Clears expired sessions and links |
Your own domain
In the Cloudflare dashboard, open Workers & Pages › kagaz › Settings › Domains & Routes and add a custom domain such as docs.example.com. Then set PUBLIC_URL under vars in wrangler.jsonc so invite links use it, and deploy again.
Why it fits the free plan
The free plan allows 10 ms of CPU time per request. Kagaz keeps the expensive work in the browser (password stretching, building print PDFs, opening locked PDFs, backups), and the Worker only does fast AES-GCM encryption and small database queries. Uploads are limited to 10 MB per file on Cloudflare, and photos are shrunk in the browser first.
Home server, NAS or Raspberry Pi
- Install Docker, then:
git clone https://github.com/bnap00/kagaz cd kagaz cp docker.env.example .env - Edit
.env: setMASTER_KEY, and setPUBLIC_URLto the address the family will use. - Start it:
docker compose up -d - Open
http://localhost:8080(or the server's address) and create the vault.
Everything lives in ./data. To use Kagaz away from home without opening ports on your router:
- Tailscale: install it on the server and on family phones, then open
http://<server-name>:8080. SetPUBLIC_URLto that address. - Cloudflare Tunnel: run
cloudflared tunnel --url http://localhost:8080, or create a named tunnel on your domain and setPUBLIC_URL=https://docs.example.com.
A free cloud VM
For example an Oracle Cloud Always Free VM running Ubuntu with Docker installed.
- Follow the Docker steps above on the VM, with
PUBLIC_URL=https://docs.example.com. - Point your domain's DNS at the VM and open ports 80 and 443.
- Add HTTPS with Caddy, which gets certificates automatically:
caddy reverse-proxy --from docs.example.com --to localhost:8080
Download a backup regularly and keep it off the VM.
Any container host
Use this on platforms that can wipe your container at any time, such as Google Cloud Run, Render or Koyeb. Nothing important lives in the container.
- Database: create a Turso database and token.
turso db create kagaz turso db show kagaz --url # DATABASE_URL turso db tokens create kagaz # DATABASE_AUTH_TOKEN - Files: create a private bucket on Cloudflare R2 or Backblaze B2, with an access key limited to that bucket.
- Run the repository's
Dockerfilewith these environment variables:MASTER_KEY=... PUBLIC_URL=https://your-app-url DATABASE_URL=libsql://kagaz-you.turso.io DATABASE_AUTH_TOKEN=... STORAGE_DRIVER=s3 S3_ENDPOINT=https://<account-id>.r2.cloudflarestorage.com S3_REGION=auto S3_BUCKET=kagaz S3_ACCESS_KEY_ID=... S3_SECRET_ACCESS_KEY=...
In this mode Kagaz refuses to start without MASTER_KEY, so a key can't be silently lost on a redeploy. Hosts that put idle apps to sleep make the first page load slower, which is fine for family use.
Upgrading
Take a backup first. Database changes are applied automatically when the new version starts.
# Docker
git pull && docker compose up -d --build
# Cloudflare
git pull && npm install && npm run build && npm run deploy