Skip to content

Bitwarden (Vaultwarden) in Docker on a Synology NAS

UpdateDate
New guide Published29/12/2021
Updated with Admin Panel Options30/12/2021
Changed the port number from 8112 to 8122 so it doesn’t conflict with Deluge01/01/2021
Updated screenshots and steps for DSM7.1 17/06/2022


What is Bitwarden/Vaultwarden?

Bitwarden (Vaultwarden) is a great way to self-host a password manager it gives you complete control over your passwords and allows you to have automatic syncing across web, desktop and mobile apps.

Let’s Begin

This guide contains three parts:

  • Part 1 — Setting up the container via the DSM GUI
  • Part 2 — Setting up DDNS, Reverse Proxy and SSL
  • Part 3 — Setting up the Bitwarden Clients

Part 1 — Container Set up (DSM GUI)

Downloading the Vaultwarden Image

Open up Docker within DSM and navigate to the ‘Registry’ section and search for ‘vaultwarden’ in the search box and download the ‘vaultwarden/server’ version

The pop-up box will ask which version you want to download, make sure you choose ‘Latest’ from the list of available versions.

Select ‘Latest’ from the tags

You can check the status of the download over on the ‘Image’ tab.

Setting up the container

In Docker click on the ‘Image’ tab, in the list of your containers select the ‘vaultwarden/server’ image and click on ‘Launch’

The first screen will ask how you want to set up the Docker network, as DSM reserves certain web ports we will be running this container in ‘Bridge’ mode which allows us to specify these later on.

General Settings

Next you will be greeted with the General Settings screen, this is where you can start specifying some of your preferences.

You can change the name of the container to anything you like, and you may want to enable Auto Restart as this will ensure Radarr starts automatically if you reboot your NAS.

You will also notice a Configure capabilities button — don’t change anything in here!

Next up we are going to click on the ‘Advanced Settings’ button, this will take you to a new window with a number of tabs which we are going to work through.

Environment

We need to add two additional variables, the first disables any random person signing up for an account on your personal hosted version, the second enables the Admin panel which allows you to invite users.

The Admin panel will be secured by the value you enter for the ‘Admin Token’ variable so make sure it is completely random and not guessable the longer, the better!

VariableValue
SIGNUPS_ALLOWEDFALSE
ADMIN_TOKENcreate a very long random string
You must come and change this to false later

You do not need to set up anything on these tabs.

Press ‘Save’ to go back to the initial setup screen, then press ‘Next’

Port Settings

As Vaultwarden uses port 80 for its web interface by default we need to change this to ensure we don’t have any conflicts with DSM’s web functions.

You will see the Container Port section prefilled you must not change these ports. Change the ‘Local ports’ from ‘Auto’ to the values below.

Local PortContainer PortType
30123012TCP
812280TCP
Port Settings

Volume Settings

We will now be specifying the directories where Vaultwarden will store its configuration files and database.

Click on Add Folder, click on the ‘docker’ share and create a new sub-folder called ‘vaultwarden’ click on this folder and click ‘select’

In the Mount path section for this folder enter ‘/data’ it should now look like the screenshot below, click next.

Summary

You have now completed the setup of the container.

You will be shown an overall summary of the settings we have specified, this is a good time to double-check everything is correct. Finally, click on Done and the container should start to boot.

You should now be able to access the web interface via the IP of your NAS followed by the port 8122

e.g 192.168.0.40:8122

Successful start up

You will not be able to register an account yet, as you must have a valid SSL certificate in place.

Part 2 – DDNS, SSL and Reverse Proxy

Before we start, make sure you have registered for a Synology Account as we are going to be using their DDNS service. https://account.synology.com/en-uk/register/

In order to successfully use reverse DNS you will also need to forward port 443 to you NAS IP. (You will need to check how to do this on your own router) This port will be used for secure web traffic.

DDNS

A DDNS address allows you to get external access to Vaultwarden and other services via a subdomain provided by Synology, this is useful on home internet connections where your ISP may change your IP address on a regular basis.

Note: If you want to access DSM via this new address you will either need to create an additional Reverse Proxy for it or open port 5001 on your router.

In the DSM Control panel go to ‘External Access’ and then to the ‘DDNS’ tab

Click on ‘Add’, then fill out the following sections.

SectionValue
Service ProviderSynology
HostnameThis can be anything it will be used to access your NAS externally
Email:Log into your Synology account
External Address (IPv4)This should be filled in automatically
External Address (IPv6)This should be filled in automatically if your ISP is using IPv6
Get a Cert from Let’s EncryptTick this box
Enable HeartbeatTick this box

Now press OK, DSM will apply your settings. It can take a few moments to set up and the DSM interface will refresh. You will likely receive a certificate error which you will need to accept to get back into DSM.

Reverse Proxy

So you don’t have to open up additional ports on your router for Vaultwarden we are going to set up a reverse proxy subdomain. This means you can access Vaultwarden without using a port number as it will route all traffic through the secure 443 port.

This can be used for any service on your NAS, it will see the address asked for and internally redirect the request to the port number specified.

Go back into the Control Panel and access the ‘Login Portal’ then in the ‘Advanced’ tab click ‘Reverse Proxy’ and then click on ‘Create’.

We are now going to enter some rules, so when you access the URL specified you will automatically be sent to Vaultwarden web UI.

Use the settings below, you will need to amend the Hostname section in line with the hostname you registered earlier, and the IP of your NAS.

SettingValue
Reverse Proxy Name:bitwarden
Protocol:HTTPS
Hostname:bitwarden.xxx.synology.me (change the part after ‘bitwarden.’ to your own hostname you registered earlier.
Port:443
Protocol:HTTP
Hostname:Your NAS IP
Port:8122

You should now be able to access the Bitwarden (Vaultwarden) web UI by going to https://bitwarden.yourhostname it will be a secure connection, and you should have no SSL errors.

SSL Working

Setting up the Admin Settings

As we disabled sign-ups via the main log in screen you will need to invite yourself and any other users from the admin panel.

Go to bitwarden.yourhostname.me/admin

Enter the admin token that you entered into the Environment Variables earlier to log in.

Admin Token

We need to change a few options to enable user sign up emails.

In General Settings. Amend the Domain URL to your own.

Domain URL

Next you will need to amend your own email settings in the SMTP Email Settings section.

This will need to be in line with your email provider, once you have entered the details click Save at the bottom of the screen, you can then send a test email to yourself to ensure its working.

SMTP Email Settings

The final step will be to send yourself an invitation email via the Users’ panel at the top of the page. This allows you to create an account by clicking the link in the email.

Users settings screen

You have now successfully set up Vaultwarden.

Part 3 — Setting Up the Bitwarden Clients.

Now you have set up Vaultwarden you can use the various Mobile, Desktop or Browser Add-ons.

It’s very easy to point these to your personal self-hosted version. In the main login screen click the Cog icon, then in the Server URL section enter the full URL for your web UI.

Self Hosted Server URL

You have now completed the guide, I have added an FAQ to page 2 of this guide.

Docker Compose

You can use the below code saved as vaultwarden.yml in ‘/docker/vaultwarden’ which will get the container set up, You will then need to follow the guide from Part 2 onwards.

version: "3.8"
services:
  vaultwarden:
    image: vaultwarden/server:latest
    container_name: vaultwarden
    environment:
      - ROCKET_ENV=staging
      - ROCKET_PORT=80
      - ROCKET_WORKERS=10
      - SIGNUPS_ALLOWED=FALSE
      - ADMIN_TOKEN=YOUROWNLONGSTRING
    volumes:
      - /volume1/docker/vaultwarden:/data
    ports:
      - 3012:3012/tcp
      - 8122:80/tcp
    restart: unless-stopped
sudo docker-compose -f /volume1/docker/vaultwarden/vaultwarden.yml up -d


Throw me some bits or buy me a coffee?

If you have found my site useful please consider pinging me a tip as it helps cover the cost of running the site, you can even buy me a coffee 🙂

Buy Me A Coffee
Doge / Ethereum / Bitcoin

Pages: 1 2

Published inDockerSynology

31 Comments

  1. BPS BPS

    Thanks for spelling this out! Got it set up so that I can get to the Bitwarden page on my LAN. But I’ve been struggling (for hours now) to get the DDNS hostname to bring me to any component of my DiskStation or the Docker/Bitwarden instance. I got an XXX.synology.me hostname issued through Synology, but even before moving on to the reverse proxy section, I’m not getting the domain to resolve to my NAS. I’ve set port 443 to forward to the IP of my NAS, and using an Open Port Check Tool online I can see that addition does have the effect of switching 443 from closed to open. Any thoughts? They’re obviously very welcome!

    • Dr_Frankenstein Dr_Frankenstein

      Hey, so this guide is next up for the DSM7.1 rewrite where I will tweak the wording of the DDNS section. By setting up the DDNS domain it won’t actually give you access to DSM, you will need to open port 5001 on your router for this. However, move to the next part of the guide and set up the reverse proxy for Bitwarden as that will work as expected. If you don’t want to open port 5001 you could actually set up another reverse proxy to take you to DSM using the same method…

  2. Joerg Joerg

    Hi, thanks for that!
    Browser login works for me (even external), but I can’t login via App / browser plugin. Neither Windows, OSX or iOS is working.
    I get the ‘Failed to fetch’ error.
    Disabled all firewalls (temporarily), opened all ports: no effect.
    Any idea where to start?

    • Dr_Frankenstein Dr_Frankenstein

      Double Check you have set the correct address in the app otherwise it will be trying to login to Bitwarden own servers.

      • Joerg Joerg

        thanks for your reply.
        done that a couple of times :-), but everthing seems fine and correct.
        I set the TZ variable also as I thought it might be the 2hrs difference between server UTC and lokal client time. No effect.
        WEB access is OK, client app does not work :(.
        I’ll keep searching and if I find a solution I’ll let you know.

  3. Nice guide! The subdomain however is redirected to the Synology login page (5001). Any ideas?

    • Dr_Frankenstein Dr_Frankenstein

      Hey, double-check your reverse proxy settings, as it should grab the URL and redirect straight to your Bitwarden login screen… try explicitly using https:// to start with when typing the address.

      • Thanks for the quick reply. Recreating a new subdomain somehow worked (with same settings).

        • Dr_Frankenstein Dr_Frankenstein

          Bizarre, it’s like the classic “did you try turning off and on again” trick

  4. Klaus Klaus

    This is a great tutorial. Many thanks. I have one question: I only have ipv6 available. Weil this still work?

    • Dr_Frankenstein Dr_Frankenstein

      Hey, yes should be fine as long as the DDNS service is updating the correct IP it should be fine.

  5. Chris Chris

    Great guide, I really enjoyed setting up my own server and everything worked flawlessly. Do you think you could extend this to show how you could create daily backups of the vaultwarden database (maybe just by zipping all required files)? From my understanding the Docker image should be stopped before copying the SQLite files? From all the setup guides you have this one is probably the most critical one to have proper backups running. Thanks and much appreciated!

    • Dr_Frankenstein Dr_Frankenstein

      Hey, thanks. I have a nightly backup running to another server with Hyperbackup. No need to stop the container as it will take a snapshot of the live file for backup. You will probably want to just do a Backup of the whole /docker share.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

drfrankenstein.co.uk – writing Synology Docker Guides since 2016 – Join My Discord!