VaultWarden - vincios/rpi-setup GitHub Wiki
VaultWarden is an unofficial Bitwarden compatible server written in Rust.
Warning
Vaultwarden requires docker.
-
Create a
vaultwarden
folder somewhere -
Clone the
docker-compose.yml
$ wget https://raw.githubusercontent.com/vincios/rpi-setup/main/General/VaultWarden/docker-compose.yml
-
Clone the default
.env
file$ wget -O .env https://raw.githubusercontent.com/vincios/rpi-setup/main/General/VaultWarden/example.env
-
Setup the
.env
file- Set the
DOMAIN
variable, edit it according to your domain - Only after first run, set
SIGNUPS_ALLOWED
to false.
- Set the
Tip
SMTP could be configured via .env
variables or via the Admin page (if enabled).
You could rely on external SMTP Severs (like Resend or these) but note that this requires you are able to verify your domain through DNS Records.
Warning
Make sure you have installed fail2ban
Follow official docs.
Default filter/jail configuration snippets should be enough (vault / admin), follow the other note and/or tips only in case of trouble.
In case of trouble, make sure you satisfy pre-requisiteş and follow accurately the tips in this paragraph.
Important
Logs file location is ./vw-data/logs/vaultwarden.log
, make sure to specify your full path into the jails configuration parameters.
-
Create the logrotate file
$ sudo nano /etc/logrotate.d/vaultwarden
-
Paste the following content
/your/logs/path/*.log { # Rotate daily daily # Rotate when the size is bigger than 5MB size 5M # Compress old log files compress # Keep 4 rotations of log files before removing or mailing to the address specified in a mail directive rotate 4 # Truncate the original log file in place after creating a copy copytruncate # Don't panic if not found missingok # Don't rotate log if file is empty notifempty # Add date instead of number to rotated log file dateext }
Important
Logs file location is ./vw-data/logs/vaultwarden.log
, make sure to specify your full path at the top of the logrotate file.
Follow Annex: Add custom dynamic configuration.
Use this example as reference.
✨ Click to see the code
http:
routers:
# We split the http router (my-router-http) from the https router (my-router) to better handle the cases where we need a http connection
# But in most cases, the http router doesn't need to be touched, since it simply redirects to the https router (where all the router configuration must be set). Just set its 'rule' and 'service' parameter> vaultwarden-http:
rule: (Host(`subdomain.{{ env "DUCKDNS_DOMAIN"}}.duckdns.org`) && PathPrefix(`/subpath/`))
entrypoints:
- web
middlewares:
- redirect-to-https
service: "vaultwarden"
vaultwarden:
rule: (Host(`subdomain.{{ env "DUCKDNS_DOMAIN"}}.duckdns.org`) && PathPrefix(`/subpath/`))
entrypoints:
- websecure
service: "vaultwarden"
# Middlewares to which the request will be forwarded when the route is activated
# Optional
middlewares:
# Enable the TLS encryption
# Normally, you should not need to edit this section
tls:
certResolver: "duckdnsResolver"
domains:
- main: "{{ env "DUCKDNS_DOMAIN"}}.duckdns.org"
sans:
- "*.{{ env "DUCKDNS_DOMAIN"}}.duckdns.org"
# Service's urls where the request will be forwarded
services:
vaultwarden:
loadBalancer:
servers:
- url: "http://127.0.0.1:8666/subpath/"
Note: Since IP access is limited to localhost (via docker-compose.yml
port), the Service IP must be http://127.0.0.1:8666
. Make sure that the reverse proxy is on the same host of the vaultwarden server.
Note: If you use a subpath (like advised here), make sure that all your subpath (like PathPrefix
or Service URL) MUST end with a trailing /
.
Note
Access via IP is limited only to localhost (see port
entry of docker-compose.yml
), so you cannot access to the service using the server LAN IP.
Make sure to setup HTTPS access via reverse proxy before to continue.
If you want to enable the Admin page and generate the ADMIN_TOKEN
via a temporary container, follow the steps 1-3.
Otherwise, skip to the step 4.
In the docker-compose.yml
folder
-
Pull the container
$ docker compose pull
-
Generate the
ADMIN_TOKEN
$ docker run --rm -it vaultwarden/server /vaultwarden hash --preset owasp
-
Paste the result into the
.env
file -
(Temporarily) enable user registration
- Set the
SIGNUPS_ALLOWED
variable into the.env
file totrue
- Set the
Tip
If the Admin page is enabled, you can skip this step and register the user via an Admin invitation mail.
-
Start the container
$ docker compose up -d
-
(Optional) Configure via Admin page
-
Create the account
-
⚠️ Disable user registration- Set the
SIGNUPS_ALLOWED
variable into the.env
file tofalse
- Set the
-
⚠️ Setup your backups!