$32

$33

$34

Architecture

 Internet │ ▼ ┌─────────────────┐ │ Cloudflare │ (optional but recommended: │ DNS + proxy │ DDoS, WAF, hide origin IP) └────────┬────────┘ │ ▼ ┌─────────────────┐ │ VPS firewall │ (ufw: only 22, 80, 443) └────────┬────────┘ │ ▼ ┌─────────────────┐ │ Caddy :443 │ (automatic Let's Encrypt cert) │ reverse proxy │ └────────┬────────┘ │ ▼ ┌─────────────────┐ │ Vaultwarden │ (container, port 80 internally) │ + WebSocket /notifications/hub └────────┬────────┘ │ ▼ ┌─────────────────┐ │ SQLite file │ (or PostgreSQL/MySQL) │ /vw-data/ │ persistent volume └─────────────────┘ 

The two key things this diagram doesn't show: the persistent volume (/vw-data) holds your SQLite database, attachment files, sends, and config. That volume is what you back up. And the /notifications/hub WebSocket endpoint is what powers live sync across your devices-don't let your reverse proxy break it.

Folder Structure

vaultwarden/ ├── docker-compose.yml # the stack ├── caddy/ │ └── Caddyfile # reverse proxy config ├── vw-data/ # persistent volume (BACK THIS UP) │ ├── db.sqlite3 # the actual vault data │ ├── attachments/ # user attachments │ ├── sends/ # Bitwarden Send files │ ├── icon_cache/ # favicons for login items │ ├── rsa_key.pem # JWT signing key (regenerated if deleted) │ └── config.json # admin-generated config ├── backups/ # local backup snapshots └── .env # secrets (admin token, SMTP creds) 

Keep this whole tree under version control except vw-data/ and .env. The compose file and Caddyfile belong in git; the data and secrets do not.

$35

The .env File

# Generate with: openssl rand -base64 48 ADMIN_TOKEN=$argon2id$v=19$m=65540,t=3,p=4$<your-hash-here> # SMTP for email verification, 2FA reset, device approval SMTP_HOST=smtp.mailgun.org SMTP_PORT=587 SMTP_FROM=vault@yourdomain.com SMTP_FROM_NAME=Vaultwarden SMTP_USERNAME=postmaster@yourdomain.com SMTP_PASSWORD=<your-smtp-password> SMTP_SECURITY=starttls # IP whitelist for admin panel (CIDR). Empty = allow all (NOT recommended) IP_HEADER=X-Real-IP 

Tighten the admin panel by IP if you can. If only your home and office need admin access, set ALLOW_ADMIN_IPS=192.0.2.0/24,198.51.100.5 (replace with your actual IPs) in the environment. The admin panel returns 404 for non-whitelisted IPs, so an attacker doesn't even know it exists.

$36

$37

$38

$39

$3a

$3b

$3c

$3d

$3e

Upgrading Vaultwarden

Upgrades are usually smooth, but always back up first:

# 1. Backup /usr/local/bin/vaultwarden-backup.sh # 2. Pull the new image (replace with the version you want) docker compose pull vaultwarden # 3. Recreate the container docker compose up -d vaultwarden # 4. Watch the logs for migration messages docker compose logs -f vaultwarden 

Vaultwarden runs SQLite migrations on startup. They're usually fast (seconds), but for very large vaults (10K+ items) they can take a minute. During migration, the server is unavailable-clients will queue requests and retry.

If a migration fails, the server won't start. Restore from backup, file an issue on the Vaultwarden GitHub, and don't try to "fix" the database manually.

Subscribe to release notifications (GitHub Watch → Custom → Releases) so you know when to upgrade. Security releases warrant prompt action; feature releases can wait a few days for the community to find bugs.

Monitoring

A simple monitoring setup:

# Healthcheck endpoint (Vaultwarden exposes /alive) curl -fsS https://vault.yourdomain.com/alive # Should return 200 with body "OK" # Add to a monitoring system (Uptime Kuma, Pingdom, etc.) # Alert on: # - /alive returns non-200 # - TLS cert expires in <14 days # - Docker container restarts >3 times in an hour # - Backup script doesn't run for >25 hours # - vw-data/ size grows >10% in a day (could indicate an issue) 

For deeper monitoring, the Vaultwarden container exposes Prometheus metrics if you set ROUTES_ENABLED=true and METRICS_TOKEN=.... The metrics endpoint is at /metrics and requires the token as a bearer. Track:

  • vaultwarden_users_total - user count
  • vaultwarden_records_total - total vault items (gauge)
  • vaultwarden_http_requests_total - request count by status

I run a Grafana dashboard on the same VPS that pulls these metrics. It's overkill for a personal instance, but for a team deployment it's worth setting up.

Cost Considerations

Item Cost Notes
VPS (Hetzner CX11, etc.) $5/month 1 vCPU, 2GB RAM is plenty
Domain $10-15/year Use Cloudflare as DNS (free)
Backblaze B2 for backups ~$0.50/month 1GB stored, no egress fees for restore
Mailgun SMTP (free tier) $0 Up to 100 emails/day
Cloudflare (free tier) $0 DNS, WAF, basic DDoS
YubiKey for 2FA $40-55 one-time Optional but recommended
Total ~$75/year Versus Bitwarden Premium at $10/year

Yes, self-hosting costs more than paying Bitwarden. You're paying for control, the learning experience, and the satisfaction of owning your data. If cost is the only consideration, pay Bitwarden. If you value independence and the ability to extend (custom plugins, integration with your homelab), self-hosting wins.

Time cost: once set up, maybe 30 minutes a month on updates and backup verification. Initial setup is 2-4 hours if you follow this guide.

$3f

$40

Conclusion

Vaultwarden is one of the most satisfying things to self-host: a single Docker container that replaces a paid service, with the same clients, end-to-end encryption, and full control over your data. The setup is a weekend afternoon; the maintenance is 30 minutes a month; the value is having your passwords under your control for as long as you care to keep the server running.

But take it seriously. Back up. Test restores. Pin image versions. Harden the admin panel. Enable 2FA. Your password vault is the highest-stakes data you'll ever manage-if you wouldn't trust yourself to recover from a catastrophic failure, pay Bitwarden $10/year instead. Self-hosting is a responsibility, not just a省钱 trick.

Originally published on Mango Developer.