A password manager holds the keys to everything else you run, which makes it one of the most sensitive services in a home lab. Hosted vaults are convenient, but many operators prefer to keep the encrypted vault data on hardware they control. Vaultwarden is a lightweight, community-maintained server that is compatible with the official Bitwarden clients, so you get the familiar apps and browser extensions while running the backend yourself.

This guide is for home-lab operators comfortable with Linux, Docker, and basic DNS. By the end you will have Vaultwarden running in Docker, served over HTTPS through nginx, with login rate limiting, an admin panel restricted to your own IP address, automated encrypted backups, and a restore procedure you have tested. Running the service is the easy part. Keeping it recoverable and hard to attack is where the real work is.

Before you start

  • A Linux host (physical or VM) with a stable LAN address and Docker Engine plus the Docker Compose plugin installed.
  • A domain you control, with a DNS A record (or AAAA record) for vault.YOUR_DOMAIN pointing at your public address, and ports 80 and 443 forwarded to the host if it is reachable from the internet.
  • nginx and certbot installed on the host, or the equivalent for your distribution.
  • The sqlite3 command-line tool and age (a simple file encryption tool) installed for backups.
  • A workstation IP address you will use to reach the admin panel, referred to below as 192.0.2.10. Replace it with your own.
  • Enough disk space for at least a few weeks of backups.

1. Lay out the host and firewall

Create a dedicated directory for the service so the data, compose file, and scripts stay together.

sudo mkdir -p /opt/vaultwarden/vw-data
sudo mkdir -p /srv/backups
cd /opt/vaultwarden

Only nginx should be reachable from outside. Allow SSH, HTTP, and HTTPS through the host firewall, and make sure Vaultwarden itself is never published on a public interface. The compose file in step 3 binds the container to 127.0.0.1 for this reason. Docker writes its own firewall rules and can bypass rules you set with ufw or firewalld for published ports, so binding to localhost is the reliable control.

sudo ufw allow OpenSSH
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable

2. Generate a hashed admin token

The admin panel at /admin is protected by an admin token. Do not store the token in plain text. Vaultwarden supports storing a hashed value (an Argon2 PHC string), and you should use that. Pull the image and run the built-in hash command. Pin the image to a specific release tag from the project’s release page rather than latest, so upgrades are deliberate.

docker run --rm -it vaultwarden/server:YOUR_PINNED_TAG /vaultwarden hash

The command prompts for a long random passphrase and prints a hashed string beginning with $argon2id$. Generate the passphrase with a password manager or openssl rand -base64 48, and store the plain passphrase in your own safe place. You will need it to log in to the admin panel. The hash goes into the compose file.

When you place the hash in a compose file, every $ must be doubled, because Compose treats a single $ as variable interpolation. A hash shown as $argon2id$v=19$m=65540,t=3,p=4$SALT$HASH becomes $$argon2id$$v=19$$m=65540,t=3,p=4$$SALT$$HASH in the file.

3. Run Vaultwarden with Docker Compose

Create /opt/vaultwarden/docker-compose.yml. The key choices here are that signups are disabled, the container listens only on localhost, and the data directory is a bind mount you can back up directly.

services:
  vaultwarden:
    image: vaultwarden/server:YOUR_PINNED_TAG
    container_name: vaultwarden
    restart: unless-stopped
    environment:
      DOMAIN: https://vault.YOUR_DOMAIN
      SIGNUPS_ALLOWED: false
      INVITATIONS_ALLOWED: true
      ADMIN_TOKEN: $$argon2id$$v=19$$m=65540,t=3,p=4$$YOUR_SALT$$YOUR_HASH
      LOG_LEVEL: warn
    volumes:
      - ./vw-data:/data
    ports:
      - "127.0.0.1:8080:80"

Start it and confirm it is healthy:

cd /opt/vaultwarden
docker compose up -d
docker compose logs --tail=50 vaultwarden

Setting SIGNUPS_ALLOWED to false means nobody can create an account from the web. You create your own account once, before you turn signups off, or you use the admin panel to invite users. Leave INVITATIONS_ALLOWED on only if you plan to invite household members. Vaultwarden also supports login rate limit settings through environment variables. Check the project wiki for the current variable names and defaults before you change them, since they are easy to misspell and the defaults are a reasonable starting point.

4. Put nginx in front with TLS

Request a certificate with certbot. This uses the nginx plugin, which also installs renewal. Replace the domain with yours.

sudo certbot certonly --nginx -d vault.YOUR_DOMAIN

Create /etc/nginx/conf.d/vaultwarden.conf. This configuration does four things: redirects HTTP to HTTPS, enforces modern TLS, forwards the headers Vaultwarden needs to generate correct links, and passes the websocket endpoint used for live sync. The rate limit zones are declared at the top and applied in step 5.

# Rate limit zones (defined in the http context via conf.d)
limit_req_zone $binary_remote_addr zone=vw_login:10m rate=10r/m;
limit_req_zone $binary_remote_addr zone=vw_general:10m rate=30r/s;

server {
    listen 80;
    server_name vault.YOUR_DOMAIN;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl;
    server_name vault.YOUR_DOMAIN;

    ssl_certificate /etc/letsencrypt/live/vault.YOUR_DOMAIN/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/vault.YOUR_DOMAIN/privkey.pem;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_prefer_server_ciphers off;

    client_max_body_size 128M;

    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
    add_header X-Content-Type-Options nosniff always;
    add_header X-Frame-Options DENY always;
    add_header Referrer-Policy no-referrer always;

    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;

    # Live sync websocket
    location /notifications/hub {
        proxy_pass http://127.0.0.1:8080;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }

    location / {
        proxy_pass http://127.0.0.1:8080;
    }
}

Note that the listen 443 ssl; line is the classic form and works across nginx versions. Newer nginx releases also accept a separate http2 on; directive if you want HTTP/2. Test the configuration before reloading it:

sudo nginx -t && sudo systemctl reload nginx

5. Add rate limiting and lock down the admin panel

Two controls matter most here. First, the login endpoint is the one an attacker will hit with password guessing. Second, the admin panel should never be reachable by the whole internet. Edit the same server block and add dedicated locations for these paths above the catch-all location /. Nginx matches the more specific prefix first, so these rules take precedence.

    # Login and token endpoint: strict rate limit
    location /identity/connect/token {
        limit_req zone=vw_login burst=5 nodelay;
        limit_req_status 429;
        proxy_pass http://127.0.0.1:8080;
    }

    # Admin panel: only from your workstation
    location /admin {
        allow 192.0.2.10;
        deny all;
        proxy_pass http://127.0.0.1:8080;
    }

Then apply the general rate limit to the catch-all location by adding this line inside location /:

        limit_req zone=vw_general burst=60 nodelay;

The deny all rule for /admin is the important one. Even if someone obtains the admin token, they cannot reach the panel from outside your allowed address. If you need access from several places, add more allow lines, or better, reach the admin panel over a VPN such as WireGuard and allow only the VPN subnet. Do not leave /admin open to the internet on the theory that the token is strong enough.

Reload nginx after editing, and remember that the login rate limit is per client IP. If you run Vaultwarden behind another proxy or load balancer, make sure the real client address reaches nginx, or every login will look like it comes from one source.

6. Set up encrypted, automated backups

The vault lives in /opt/vaultwarden/vw-data, mainly in db.sqlite3, plus attachments, sends, and key files. Do not back it up by copying the database file while the service is running. SQLite can be mid-write, and a plain copy may be inconsistent. The .backup command in the sqlite3 tool uses SQLite’s backup mechanism and produces a consistent snapshot even while the database is in use.

Create /opt/vaultwarden/backup.sh. It takes a consistent database snapshot, packages the rest of the data directory, encrypts the bundle with age, and prunes old copies.

#!/bin/bash
set -euo pipefail

DATA_DIR=/opt/vaultwarden/vw-data
DEST=/srv/backups
RECIPIENT=YOUR_AGE_PUBLIC_KEY
STAMP=$(date +%F-%H%M)
TMP=$(mktemp -d)
trap 'rm -rf "$TMP"' EXIT

# Consistent snapshot of the live database
sqlite3 "$DATA_DIR/db.sqlite3" ".backup $TMP/db.sqlite3"

# Everything else, excluding the live database files and cache
tar -C /opt/vaultwarden -czf "$TMP/vw-data-files.tgz" \
  --exclude=vw-data/db.sqlite3 \
  --exclude=vw-data/db.sqlite3-wal \
  --exclude=vw-data/db.sqlite3-shm \
  --exclude=vw-data/icon_cache \
  vw-data

# Bundle and encrypt
tar -C "$TMP" -czf - . | age -r "$RECIPIENT" > "$DEST/vw-$STAMP.tar.gz.age"

# Keep 30 days of backups
find "$DEST" -name 'vw-*.tar.gz.age' -mtime +30 -delete

echo "Backup complete: vw-$STAMP.tar.gz.age"

Generate an age key pair on a machine other than the server if you can. Keep the private key somewhere safe and offline, such as a password manager that is not this vault, or a printed copy in a secure location. The server needs only the public key. A backup you cannot decrypt is worthless, so this key is as important as the data.

age-keygen -o age-key.txt
# The line starting with "age1" is your public recipient key

Make the script executable and schedule it with cron. Then copy the encrypted files off the host, because a backup on the same disk does not protect you from disk failure or theft.

chmod 750 /opt/vaultwarden/backup.sh
(crontab -l 2>/dev/null; echo '30 2 * * * /opt/vaultwarden/backup.sh >> /var/log/vw-backup.log 2>&1') | crontab -

# Nightly offsite copy after the backup finishes
(crontab -l; echo '0 3 * * * rsync -a /srv/backups/ backup@BACKUP_HOST:/srv/vault-backups/') | crontab -

7. Test a restore

A backup process is unproven until you restore from it. Do this on a scratch directory, not on the live data, and do it now rather than during an emergency.

mkdir -p /tmp/vw-restore-test
LATEST=$(ls -t /srv/backups/vw-*.tar.gz.age | head -n 1)
age -d -i ~/.config/age/age-key.txt "$LATEST" | tar -xz -C /tmp/vw-restore-test

# Check that the restored database is intact
sqlite3 /tmp/vw-restore-test/db.sqlite3 "PRAGMA integrity_check;"

The integrity check should print ok. To prove the restored data is usable, start a throwaway container against the restored files on a different port, then log in with your own account and confirm your entries are present. Do not point this test at your production port or your production data directory.

docker run --rm -d --name vw-test -p 127.0.0.1:8099:80 \
  -v /tmp/vw-restore-test:/data vaultwarden/server:YOUR_PINNED_TAG
# Connect a client to http://127.0.0.1:8099, log in, check a few entries
docker stop vw-test
rm -rf /tmp/vw-restore-test

Write down the procedure in a short runbook stored with your key material, including where the age private key lives. Repeat the restore test after any significant change, and at least every few months.

Verify it worked

Work through these checks before you trust the service with real credentials.

  • TLS and headers: run curl -sI https://vault.YOUR_DOMAIN and confirm you see a 200 response with Strict-Transport-Security present. Check that http://vault.YOUR_DOMAIN returns a 301 to HTTPS.
  • Vaultwarden is not directly exposed: from a machine outside your network, try reaching the host on port 8080. It should fail. Run ss -tlnp | grep 8080 on the host and confirm it is bound to 127.0.0.1.
  • Admin panel restriction: from your allowed address, https://vault.YOUR_DOMAIN/admin should load the login page. From any other address it should return 403.
  • Login rate limiting: send a short burst of invalid login attempts with a test client and confirm that responses begin returning 429 after the burst allowance is used. Do this against a throwaway account, not your real one.
  • Signups are closed: the web vault should not offer account creation to an unauthenticated visitor.
  • Backups exist and decrypt: confirm a new file appears in /srv/backups after the cron run, and that the restore test in step 7 succeeds.

Common mistakes

  • Publishing the container on all interfaces. Writing "80:80" or "8080:80" in the compose file exposes Vaultwarden directly, bypassing nginx’s controls. Keep the localhost binding.
  • Forgetting to double the dollar signs in the admin hash. Compose will silently mangle the value, and the admin panel will reject the token. Check the rendered value with docker compose config.
  • Copying a live SQLite file as a backup. Use sqlite3 .backup, as in step 6, not cp.
  • Storing the backup key on the server. If the server is compromised and the age private key is there, your encrypted backups are readable to the attacker. Keep the private key off the host.
  • Never testing restores. An untested backup is a hope, not a backup. Schedule the restore test like any other maintenance task.
  • Using latest in production. Pin to a specific release tag and upgrade on purpose, after reading the release notes and taking a fresh backup first.
  • Leaving the admin panel open to the internet. The token is one layer. The IP restriction or VPN is the second layer that keeps a leaked token from becoming an incident.
  • Skipping the offsite copy. Local backups fail together with the disk they live on.

Takeaway

A self-hosted vault is only as good as its surrounding controls. You now have Vaultwarden bound to localhost, fronted by nginx with TLS, a strict limit on login attempts, an admin panel restricted to known addresses, and encrypted backups that you have restored successfully. Keep the image pinned, read release notes before upgrades, take a backup before every change, and rerun the restore test on a regular schedule. Those habits matter more than any single setting.