1. Prepare the Server and Domain
Order a VPS with Ubuntu 24.04, secure it, and install Docker. Create an A record such as vault.example.com pointing at the server, and allow ports 80 and 443 in the firewall; Caddy needs both to get its certificate.
2. Write the Compose File
In a folder such as ~/vaultwarden, create compose.yaml:
services:
vaultwarden:
image: vaultwarden/server:latest
container_name: vaultwarden
restart: always
environment:
DOMAIN: "https://vault.example.com"
SIGNUPS_ALLOWED: "true" # set to "false" after creating your account
volumes:
- ./vw-data:/data
caddy:
image: caddy:2
container_name: caddy
restart: always
ports:
- "80:80"
- "443:443"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile:ro
- ./caddy-data:/data
- ./caddy-config:/configAnd a Caddyfile beside it:
vault.example.com {
reverse_proxy vaultwarden:80
}Only Caddy publishes ports; Vaultwarden is reachable only through it. Start both and watch Caddy fetch the certificate:
docker compose up -d docker compose logs -f caddy
3. Create Your Account, Then Close Sign-ups
Open https://vault.example.com, create your account with a strong master password, and log in from the Bitwarden apps by choosing the self-hosted option and entering the same address. Then stop anyone else from registering:
# compose.yaml
SIGNUPS_ALLOWED: "false"
docker compose up -d4. Protect the Admin Page
The admin page at /admin stays off until you set ADMIN_TOKEN. Store a hash, not the password itself. Generate one with Vaultwarden's own command:
docker run --rm -it vaultwarden/server /vaultwarden hash
It prints a string starting with $argon2id$. In compose.yaml, every $ must be doubled to $$, or Compose treats it as a variable:
ADMIN_TOKEN: "$$argon2id$$v=19$$m=65540,t=3,p=4$$...rest of the hash..."
Run docker compose config to check it came through intact, then docker compose up -d. Settings saved on the admin page go into config.json in the data folder and take priority over the compose file.
5. Back It Up Every Night
Everything is in vw-data: the database, attachments, sends, the key that signs logins and the config. Copy the database safely while it runs, then send the folder off the server:
sudo apt install -y sqlite3 sudo mkdir -p /var/backups/vaultwarden sudo sqlite3 ~/vaultwarden/vw-data/db.sqlite3 ".backup '/var/backups/vaultwarden/db.sqlite3'" sudo rsync -a --exclude 'db.sqlite3*' ~/vaultwarden/vw-data/ /var/backups/vaultwarden/
Then copy /var/backups/vaultwarden to a storage box or object storage, for example with Borg, from a nightly timer. Test a restore on a spare server once, so you know it works before you need it.
Keeping It Safe
- Update regularly:
docker compose pull && docker compose up -d. - Turn on two-step login for your account in the web vault.
- Keep SSH to keys only, and nothing else open besides 80 and 443.
- To keep the vault off the public internet entirely, reach it over WireGuard and give Caddy a certificate through a DNS challenge instead.