← Start of tutorial

WIUNIX ACADEMY

Self-host Vaultwarden with HTTPS, restricted admin access and consistent backups

Page 3 of 5. Review the earlier steps and prerequisites before continuing.

YOUR SYSTEM. YOUR STEPS.

Where are you working?

Choose your OS and version. The prerequisites, commands and troubleshooting follow your environment.

Manjaro Stable (rolling)Reviewed against official documentation ·

USE YOUR OWN VALUES

Configure this tutorial

Set the example values for your environment; related explanations and copy panels update together. Never enter passwords, private keys or tokens. Values stay in this tab and are not sent to the server or share links. Check actual DNS, certificates and network policy before running commands.

Different IP addresses, domains or ports? Open the settings below, change the values and select “Apply to tutorial”, then copy the updated commands.

Set values for my environment7 editable values
07

LET’S BUILD

Start the pinned loopback service

Run after saving settings. The container uses nonroot 23159, a read-only root filesystem and a writable private data mount. Docker administrators can still read mounted secrets: access to Docker is privileged. Only127.0.0.1:8159 is published; do not replace it with0.0.0.0. A restart policy is not a reboot acceptance test.

bash

Dedicated Vaultwarden VM

set -eu
sudo docker pull 'docker.io/vaultwarden/server:1.37.5@sha256:4fe17f415f90087377d37c755e0ea3cf189dcc6794e49cdd2a9adbb4937d9e1f'
sudo docker run -d --name 'academy_vaultwarden' --restart unless-stopped \
  --user '23159:23159' --cap-drop ALL \
  --security-opt no-new-privileges:true --read-only \
  --tmpfs /tmp:rw,noexec,nosuid,size=64m \
  --env-file '/srv/academy-vaultwarden/config/settings.env' \
  --mount 'type=bind,src=/srv/academy-vaultwarden/data,dst=/data' \
  --mount 'type=bind,src=/srv/academy-vaultwarden/secrets/admin.phc,dst=/run/secrets/admin.phc,readonly' \
  -p '127.0.0.1:8159:8000' \
  --entrypoint /vaultwarden 'docker.io/vaultwarden/server:1.37.5@sha256:4fe17f415f90087377d37c755e0ea3cf189dcc6794e49cdd2a9adbb4937d9e1f'
ready=no
for attempt in $(seq 1 30); do
  status=$(curl --silent --max-time 2 --output /dev/null --write-out '%{http_code}' 'http://127.0.0.1:8159/alive' || true)
  if test "$status" = 200; then ready=yes; break; fi
  sleep 1
done
test "$ready" = yes
sudo ss -lntp 'sport = :8159'
How do I know it worked?

The /alive probe reaches200 and ss shows only loopback 8159.

08

LET’S BUILD

Validate already provisioned trusted TLS

Provision the certificate chain as fullchain.pem and private key as privkey.pem inside the new TLS directory using your existing protected certificate procedure. Keep both root-owned0600. Never paste key content into this article or a command argument. The paths are shown in the next command; it does not issue a certificate.

The checks confirm matching public keys, SAN and at least7 days remaining. They do not prove a valid public trust chain, DNS routing or future renewal. A private CA must already be trusted by every intended client; never use insecure TLS bypass flags.

bash

Dedicated Vaultwarden VM

set -eu
sudo test -s '/srv/academy-vaultwarden/tls/fullchain.pem'
sudo test -s '/srv/academy-vaultwarden/tls/privkey.pem'
sudo openssl x509 -in '/srv/academy-vaultwarden/tls/fullchain.pem' -noout -checkhost 'vault.example.com'
sudo openssl x509 -in '/srv/academy-vaultwarden/tls/fullchain.pem' -noout -checkend 604800
sudo python3 - <<'PY'
import subprocess,stat
from pathlib import Path
r=Path('/srv/academy-vaultwarden/tls')
for name in ('fullchain.pem','privkey.pem'):
    p=r/name;assert stat.S_ISREG(p.lstat().st_mode) and p.stat().st_uid==0 and not p.stat().st_mode & 0o077
cert=subprocess.check_output(['openssl','x509','-in',str(r/'fullchain.pem'),'-pubkey','-noout'])
certkey=subprocess.check_output(['openssl','pkey','-pubin','-outform','DER'],input=cert)
key=subprocess.check_output(['openssl','pkey','-in',str(r/'privkey.pem'),'-pubout','-outform','DER'])
assert certkey==key, 'Certificate/key mismatch'
print('SAN, expiry window, private modes and matching key: OK')
PY
How do I know it worked?

Correct SAN, matching key and sufficient remaining validity; private modes pass.

09

LET’S BUILD

Open the dedicated Nginx configuration

Open the precreated file and copy the whole next panel. This file belongs inside Nginx http context. The map has a fixed dedicated-service name; academy_vaultwarden selects the configuration filename and container. Admin requests are allowed only from 203.0.113.10/32, evaluated from the direct TCP peer. Do not add real_ip trust, a CDN or blanket allow as a shortcut.

bash

Dedicated Vaultwarden VM

sudo env HOME=/root nano --ignorercfiles --restricted --noread -- '/srv/academy-vaultwarden/config/nginx.conf'
How do I know it worked?

The full proxy file is saved with the chosen admin source network.

HTTPS proxy and restricted admin path

The proxy replaces client-supplied identity/scheme headers, preserves WebSocket upgrade on the same backend port and sets an explicit 32MiB HTTP-body ceiling. This is not a per-vault storage quota. Unknown Host returns421. Access logs are disabled here to avoid retaining vault-related paths; review protected error logs without exporting credentials.

nginx · /srv/academy-vaultwarden/config/nginx.conf
map $http_upgrade $academy_vaultwarden_upgrade {
    default upgrade;
    '' "";
}
server {
    listen 443 ssl;
    server_name vault.example.com;
    if ($host != vault.example.com) { return 421; }
    ssl_certificate /srv/academy-vaultwarden/tls/fullchain.pem;
    ssl_certificate_key /srv/academy-vaultwarden/tls/privkey.pem;
    ssl_protocols TLSv1.2 TLSv1.3;
    client_max_body_size 32m;
    access_log off;
    error_log /var/log/nginx/academy_vaultwarden-error.log error;
    proxy_http_version 1.1;
    proxy_set_header Host vault.example.com;
    proxy_set_header X-Forwarded-Proto https;
    proxy_set_header X-Forwarded-Host vault.example.com;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Forwarded "";
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $academy_vaultwarden_upgrade;
    proxy_connect_timeout 5s;
    proxy_read_timeout 300s;
    proxy_send_timeout 300s;
    proxy_next_upstream off;
    location ~* ^/admin(?:/|$) {
        allow 203.0.113.10/32;
        deny all;
        proxy_pass http://127.0.0.1:8159;
    }
    location / {
        proxy_pass http://127.0.0.1:8159;
    }
}
10

LET’S BUILD

Check the active Nginx include layout

The packaged Nginx configuration may omit conf.d from http. Preserve a private exclusive before-copy, then edit the existing main file. If the backup name already exists, reconcile the earlier edit rather than deleting or overwriting it.

The next file panel belongs exactly once inside http; leave an existing copy intact. Do not place it inside server or outside http, and preserve all existing configuration/includes. Validate syntax and later verify the exact service-file inclusion.

bash

Dedicated Vaultwarden VM

set -eu
sudo install -d -m 0755 /etc/nginx/conf.d /var/log/nginx
sudo python3 - <<'PY'
import os,stat
from pathlib import Path
p=Path('/etc/nginx/nginx.conf')
assert stat.S_ISREG(p.lstat().st_mode) and p.stat().st_uid==0
fd=os.open('/etc/nginx/nginx.conf.before-vaultwarden',os.O_WRONLY|os.O_CREAT|os.O_EXCL|os.O_NOFOLLOW,0o600)
with os.fdopen(fd,'wb') as f: f.write(p.read_bytes())
PY
sudo env HOME=/root nano --ignorercfiles --restricted --noread -- /etc/nginx/nginx.conf
sudo nginx -t
How do I know it worked?

Identify the conf.d include within http; if absent, add it using the selected-environment instructions before continuing.

Nginx http-context include

This line belongs in the main Nginx http context; leave it unchanged where already present. Arch/Manjaro operators check it as described above.

nginx · /etc/nginx/nginx.conf
include /etc/nginx/conf.d/*.conf;
Explore all tutorials ↗