Of particular interest is the bitwarden-nginx container. You can see that it is configured to expose ports 80, 8080 and 8443 for communications with other containers on the same network. You can access Bitwarden in your browser with If you access it with the http protocol, Nginx will redirect your request to a https connection.
I use a self-hosted bitwarden-rs to manage my passwords, and it works greatexcept using docker to run it was using most of the RAM on my cheap VPS fromVultr. Since bitwarden-rs is just a rust program that uses around 16MB of RAM,it seemed overkill to have docker running around it using over 100MB.
I cloned the repository, checked out the latest tag and then ran
- Installing bitwarden with already running nginx Hi, I'm trying to install bitwarden on my server (dedicated server with Ubuntu 18.04), on wich I'm currently running Quickbox Pro 2.3.1. I followed the install instruction here with docker and docker-compose.
- Nov 02, 2020 I have a DSM918 running a number of containers in Docker. I have set up linuxserver’s swag as my secure nginx, and I seem to be having a lot of trouble getting bitwardenrs behind it. Here’s my docker-compose for bitwarden (I have to docker-compose up -no-start because I’ve set up a custom bridge network and can’t fathom how to get the right syntax to connect the container to it when.
- Bitwarden App behind a nginx web server You’ll notice that there are two nginx servers in the setup above, one in the WordPress app and one in the Bitwarden app. The solution here, as I learned in the discussion linked to above, was putting the two nginx services on their own external Docker network and configuring Bitwarden properly.
- Bitwardenrs docker container with Nginx Proxy Manager. After purchasing a domain (mine was on namecheap for like $9), you can have this up and running in about 15 minutes.
You can use postgresql or mysql if you want but sqlite suites my needs as a single user just fine.
You then need the web UI. Since this is nodejs it takes a lot of RAM to buildso I would recommend just getting the latest release from their web vaultreleases. The version I got was 2.12.0. Extract it to a folder web-fault
.
I then setup what will be the app directory; I used /opt/bitwarden
but you can use whatever you like.
You will need to run the bitwarden_rs application, but systemd makes this veryeasy. I setup /etc/systemd/system/bitwarden.service
Bitwarden Nginx File
and then enabled and ran it with systemctl enable --now bitwarden.service
Then you just need to have a web server to run it, preferably with some SSLsupport. This is how my nginx configuration looks for it.
I made some extra conf files that all my domains source for nginx to easilymanage Let’s Encrypt and SSL settings, see my blog post about it.
And now it should be done. Without a lot of effort you have saved yourself thehassle of running a docker container and are saving some precious memory.
Bitwarden is an open-source password manager. Using Bitwarden_rs, it is possible to create a self-hosted server, using little resources, enabling you to use all its features.
Bitwarden makes it possible to share and sync usernames and passwords across all devices and webbrowsers.
In this example I’ll be using two pc’s: One for compiling and one for hosting, because the VPS I run this on isn’t powerful enough to compile the binaries.
On compile machine
Install dependencies
Compile bitwarden_rs
Compile vault
Clone and checkout repository
Patch web vault to work with Bitwarden RS
Download the most recent Bitwarden_RS patch for the Bitwarden web vault. This can be done using one of two ways:
A. Download and apply a patch based on the version that you just checked out using git.
B. Does this give a 404 Not Found
error? In that case there might not be new changes in the most recent Bitwarden web release that need to be patched in order to work with Bitwarden RS.
- Go to https://github.com/dani-garcia/bw_web_builds/tree/master/patches.
- Click on the patch that is closest to the version you checked out in git (visible by executing the command
git tag --sort=v:refname | tail -n1
). - Click on “raw” to get a direct link to the patch file.
- Download with
wget
and usegit apply
.
For example:
Build the web vault
NB: Do not run the following commands as root. Building the web vault will fail.
Copy
on remote host
Use this file as a template. Alter all uncommented variables to match your environment.
Add nginx vault.conf. The following config assumes that you have already installed and configured certbot / letsencrypt and retrieved a certificate.
Set up Fail2ban
If you are using Fail2Ban, you can add this configuration to keep out unwanted guests:
Set up logrotation
Over time, the Bitwarden_RS log file can grow to a significant size. Using logrotate, we can periodically rotate logs.
NB: To view a compressed log file without manually decompressing:
Backup
If you’d like to backup the bitwarden server, please use the following steps to do so
Export the sqlite database:
If you have already set up backups for other services, add these paths to your list of backup targets:
Bitwarden Nginx Config
Upgrade Bitwarden RS and web vault
On build machine
Update system packages
Remove old build and sources
Upgrade Rust
Build Bitwarden RS
Build Bitwarden web vault
Clone Bitwarden web vault repository
Download the most recent Bitwarden_RS patch for the Bitwarden web vault
This can be done using one of two ways:
A. Download and apply a patch based on the version that you just checked out using git.
B. Does this give a 404 Not Found
error? In that case there might not be new changes in the most recent Bitwarden web release that need to be patched in order to work with Bitwarden RS.
- Go to https://github.com/dani-garcia/bw_web_builds/tree/master/patches.
- Click on the patch that is closest to the version you checked out in git (visible by executing the command
git tag --sort=v:refname | tail -n1
). - Click on “raw” to get a direct link to the patch file.
- Download with
wget
and usegit apply
.
For example:
Compile web vault
Bitwarden Rs Docker Compose
Copy upgraded binary and vault
On remote / public machine
Update notes
- 2020-07: Improved web-vault instructions, added upgrade steps.
- 2020-08: Noticed missing nginx config example. Added this.
- 2020-09: Added some cleanup steps.
- 2020-10: Updated to latest versions. Added new configuration options. Include MySQL and PostgreSQL backends next to the existing SQLite backend in compile steps.
- 2020-12: Update to latest versions. Added logrotate config.
- 2021-04: A reader notified me that the Bitwarden admin Fail2ban regex in
/etc/fail2ban/filter.d/bitwarden-admin.conf
should be updated. Bitwarden no longer prepends the log entry with “Unauthorized Error: “. This has been corrected.