A password manager is one of the most sensitive services you can run at home. If it fails, you lose access to everything else, and if it is exposed carelessly, it becomes a high-value target. Vaultwarden is a lightweight, community-maintained server that implements the Bitwarden client API, so the official apps and browser extensions work against it. Running it yourself is practical, but the defaults are not hardened, and the operational pieces (TLS, admin access, backups) are where most home-lab deployments go wrong.

This guide is for home-lab operators and self-hosting enthusiasts who are comfortable with Linux, Docker, and a basic command line. By the end, you will have Vaultwarden running behind a reverse proxy with valid TLS, the admin panel restricted to your own network, signups disabled, a FIDO2 security key registered for login, and a backup routine that you have actually tested by restoring.

Before you start

  • A Linux host (a small server, mini PC, or VM) with a static LAN address and Docker Engine and the Docker Compose plugin installed.
  • A domain name you control, with the ability to create a DNS record such as vault.YOUR_DOMAIN. You do not need to expose your home network to the internet for TLS to work, but you do need a public domain for certificate issuance through a method your DNS provider supports, or you must publish the host through a port-forward with ports 80 and 443 reachable.
  • A FIDO2 security key (for example, a hardware key that supports WebAuthn) and a spare key if you can get one.
  • sqlite3 installed on the host, and a second location for backups (an external disk, a NAS, or an offsite bucket).
  • Access to a VPN or a trusted LAN subnet from which you will administer the server. You will use its CIDR range in the proxy configuration.

1. Prepare the host and firewall

Create a project directory and open the firewall so that only SSH and the two web ports are reachable. Allow SSH before you enable the firewall, or you may lock yourself out.

sudo mkdir -p /opt/vaultwarden/vw-data
cd /opt/vaultwarden
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow OpenSSH
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw allow 443/udp
sudo ufw enable
sudo ufw status verbose

Port 80 is needed for HTTP to HTTPS redirection and for certificate issuance. Port 443/udp is used for HTTP/3 and can be omitted if you prefer. Note that Docker manipulates iptables directly, so a published container port can bypass UFW rules. That is why this design publishes only the proxy and never the Vaultwarden container itself.

Create a DNS A record (and AAAA record, if you use IPv6) for vault.YOUR_DOMAIN that points to your public address. If your host is on a private LAN, you can instead use a split-horizon DNS record that resolves to the LAN address, but the certificate step then requires a DNS challenge provider. Keep the rest of the guide the same.

2. Generate a hashed admin token

Vaultwarden’s /admin panel is powerful: it can view users, change settings, and delete accounts. Never store the admin token in plain text. Vaultwarden accepts an Argon2 hash of the token, so the plain value never appears in your configuration. Pick a long passphrase, then generate the hash using the binary bundled with the image. Replace VAULTWARDEN_TAG with the image tag you intend to pin (see step 4).

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

The command prompts for the token twice and prints an Argon2 PHC string beginning with $argon2id$. Copy that output and store the plain passphrase in your password manager (or on paper) so you can log into the admin panel later. Keep the hash for the next step.

3. Pin the image and write the Compose file

Pin both images to specific tags and check the Vaultwarden project’s release notes for the current stable version before you deploy. Floating tags such as latest make upgrades unpredictable. Vaultwarden is not published on the same network as the proxy and has no host port mapping. Create /opt/vaultwarden/docker-compose.yml:

services:
  vaultwarden:
    image: vaultwarden/server:VAULTWARDEN_TAG
    container_name: vaultwarden
    restart: unless-stopped
    environment:
      DOMAIN: https://vault.YOUR_DOMAIN
      SIGNUPS_ALLOWED: "false"
      INVITATIONS_ALLOWED: "false"
      ADMIN_TOKEN: $$argon2id$$v=19$$m=65540,t=3,p=4$$YOUR_HASH_FROM_STEP_2
      LOG_LEVEL: warn
    volumes:
      - ./vw-data:/data
    expose:
      - "80"
    networks:
      - proxy

  caddy:
    image: caddy:2.CADDY_PATCH_TAG
    container_name: caddy
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
      - "443:443/udp"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile:ro
      - caddy_data:/data
      - caddy_config:/config
    networks:
      - proxy

networks:
  proxy:

volumes:
  caddy_data:
  caddy_config:

Two details matter here. First, Compose treats $ as variable interpolation, so every dollar sign in the Argon2 hash must be doubled as $$. A single $ produces a silently broken token. Second, SIGNUPS_ALLOWED is set to false from the start. You will create your account by temporarily enabling signups or by using the admin invitation flow, then leave the setting disabled. Replace CADDY_PATCH_TAG with a specific Caddy 2 release tag rather than a floating one.

4. Configure Caddy for TLS and restrict the admin panel

Caddy obtains and renews certificates from a public certificate authority automatically, and it redirects HTTP to HTTPS by default. The configuration below adds security headers, restricts /admin to your trusted subnet, and forwards everything else to Vaultwarden. Replace the example subnets with your own VPN or LAN ranges. Create /opt/vaultwarden/Caddyfile:

vault.YOUR_DOMAIN {
    encode zstd gzip

    header {
        Strict-Transport-Security "max-age=31536000; includeSubDomains"
        X-Content-Type-Options "nosniff"
        X-Frame-Options "SAMEORIGIN"
        Referrer-Policy "same-origin"
        -Server
    }

    @admin_denied {
        path /admin /admin/*
        not remote_ip 10.8.0.0/24 192.168.1.0/24
    }

    handle @admin_denied {
        respond 403
    }

    handle {
        reverse_proxy vaultwarden:80
    }
}

The handle blocks ensure that the denied-admin rule is evaluated before the general proxy rule, regardless of directive ordering. If Caddy sits behind another load balancer, the remote_ip matcher sees that load balancer’s address, so you must configure trusted proxies or restrict access at the network level instead. Do not add a Content Security Policy header until you have tested it, because the web vault relies on inline resources and a strict policy can break login.

5. Start the stack and confirm certificate issuance

Bring the stack up and watch the Caddy logs while it requests a certificate. The first issuance can take a minute. If it fails, the logs will say why (usually a DNS record that does not yet resolve or a blocked port 80).

cd /opt/vaultwarden
docker compose up -d
docker compose logs -f caddy

Wait for a line indicating that the certificate was obtained for vault.YOUR_DOMAIN, then press Ctrl+C to stop following the log. If you ever need to check the certificate from another machine, run openssl s_client -connect vault.YOUR_DOMAIN:443 -servername vault.YOUR_DOMAIN and confirm the issuer and validity dates.

6. Create your account and enable FIDO2 two-factor authentication

Open https://vault.YOUR_DOMAIN in a browser and create your account. Because SIGNUPS_ALLOWED is false, the create-account option will not appear. Temporarily set it to true, run docker compose up -d, create your account, then set it back to false and bring the stack up again. Confirm that the signup option is gone before you continue.

Next, enable hardware two-factor authentication. In the web vault, go to Settings, then Security, then Two-step login, and choose FIDO2 WebAuthn. Enter your master password, insert your first security key, and follow the prompt to touch it. Repeat the process with your spare key and give it a distinct name. Then open the recovery code option and save the code offline, since it is the only way back in if you lose every key.

FIDO2 is bound to the origin, so the DOMAIN value in your Compose file must exactly match the URL you use in the browser, including the https:// prefix. If you later change domains, you must re-register your keys. Keep the master password and recovery code separate from each other and from the keys.

7. Automate encrypted backups

Vaultwarden stores everything under /data, which is bind-mounted to ./vw-data on the host. The SQLite database must be copied with SQLite’s own backup mechanism, not with a raw file copy, because copying a live database can produce an inconsistent snapshot. The remaining files (RSA keys, attachments, sends, and icon cache) can be archived with tar. Encrypt the archive before it leaves the host. The script below uses age, which you should install first. Replace YOUR_AGE_PUBLIC_KEY with a public key whose private half is stored safely off this host.

sudo mkdir -p /srv/backups/vaultwarden
sudo tee /opt/vaultwarden/backup.sh >/dev/null <<'EOF'
#!/usr/bin/env bash
set -euo pipefail

SRC=/opt/vaultwarden/vw-data
DEST=/srv/backups/vaultwarden
STAMP=$(date +%Y%m%d-%H%M%S)
RECIPIENT=YOUR_AGE_PUBLIC_KEY

mkdir -p "$DEST"

# Consistent SQLite snapshot (safe while the server is running)
sqlite3 "$SRC/db.sqlite3" ".backup '$DEST/db-$STAMP.sqlite3'"

# Archive everything else, excluding live database files, and encrypt it
tar -C "$SRC" --exclude='db.sqlite3*' -cf - . | age -r "$RECIPIENT" -o "$DEST/data-$STAMP.tar.age"

# Retain 30 days locally
find "$DEST" -type f -mtime +30 -delete
EOF
sudo chmod 700 /opt/vaultwarden/backup.sh

Note that the database snapshot in this script is not encrypted. Either encrypt it with age as well, or keep the backup directory on a volume with restricted permissions and encrypt when you copy it offsite. Plaintext copies of your vault database are as sensitive as the vault itself. Schedule the script with cron and log its output:

sudo crontab -e
# add this line:
0 3 * * * /opt/vaultwarden/backup.sh >> /var/log/vw-backup.log 2>&1

Copy the encrypted archives to a second location on a different disk or machine. A backup that lives only on the same disk as the service is not a backup.

8. Test a restore on a scratch instance

A backup you have never restored is a hope, not a backup. Restore into a separate directory and run a throwaway container on a loopback-only port, so nothing reaches the internet. Decrypt the archive with the private key that matches your public key, and copy in the database snapshot.

RESTORE=/tmp/vw-restore-test
mkdir -p "$RESTORE"
age -d -i /path/to/your/age-private-key.txt /srv/backups/vaultwarden/data-LATEST.tar.age | tar -C "$RESTORE" -xf -
cp /srv/backups/vaultwarden/db-LATEST.sqlite3 "$RESTORE/db.sqlite3"

docker run -d --name vw-restore-test \
  -e DOMAIN=http://127.0.0.1:8080 \
  -v "$RESTORE":/data \
  -p 127.0.0.1:8080:80 \
  vaultwarden/server:VAULTWARDEN_TAG

Open http://127.0.0.1:8080 through an SSH tunnel or directly on the host, log in with your account, and confirm that your items, attachments, and two-factor settings are present. When you are satisfied, remove the test container and the scratch directory with docker rm -f vw-restore-test and rm -rf /tmp/vw-restore-test. Record the date of your last successful test somewhere you will see it.

Verify it worked

Run these checks from a machine outside your trusted network (for example, a phone on cellular data) and from a machine inside it.

  • TLS and headers: run curl -sI https://vault.YOUR_DOMAIN and confirm a valid HTTP/2 or HTTP/3 response that includes the strict-transport-security header. Plain HTTP should redirect to HTTPS.
  • Admin restriction: from outside the trusted subnets, curl -s -o /dev/null -w "%{http_code}" https://vault.YOUR_DOMAIN/admin should return 403. From inside the trusted subnet, the admin login page should load.
  • No direct exposure: run docker ps and confirm that only the Caddy container publishes ports. Vaultwarden should show no host port mapping.
  • Signups closed: the web vault should show no create-account option to an anonymous visitor.
  • Two-factor login: log out and log in again. You should be prompted for a security key, and a second registered key should also work.
  • Backups: confirm that /var/log/vw-backup.log shows a clean run and that the encrypted archive exists. Confirm the restore test from step 8 succeeded.

Common mistakes

  • Single dollar signs in the admin hash. Compose interpolates $, so the hash must use $$. A malformed hash makes the admin panel unusable without any obvious error.
  • Publishing the Vaultwarden port. Adding ports: - "8080:80" exposes the application directly and bypasses the proxy’s admin restriction and headers. Docker also bypasses UFW for published ports, so the firewall will not save you.
  • Copying the live SQLite file. A raw copy of db.sqlite3 can be inconsistent. Use the .backup command shown above.
  • Never testing restores. Missing RSA key files, wrong permissions, or an unencrypted copy that nobody can decrypt are common failures that only appear during a restore.
  • Mismatched domain and FIDO2 origin. Changing the hostname or scheme after registering keys will make the keys fail. Decide on the final URL before enrolling.
  • Losing every second factor. Registering one key and discarding the recovery code is a single point of failure. Keep a spare key and an offline recovery code.
  • Floating image tags. Using latest for Vaultwarden or Caddy makes upgrades unpredictable. Pin tags, read release notes, and take a backup before each update with docker compose pull followed by docker compose up -d.
  • Leaving signups open. If you forget to set SIGNUPS_ALLOWED back to false, anyone who finds the URL can create an account on your server.

Takeaway

A self-hosted password manager is only as safe as its weakest operational habit. The core pattern here is simple: keep the application off the public network except through a proxy that terminates TLS and restricts admin functions, require hardware-backed two-factor authentication, and treat backups as a process you prove works by restoring them. Pin your versions, keep an offline recovery path, and check the verification list every few months. Doing those things consistently is what turns a home-lab service into something you can trust with your credentials.