Skip to content

Vaultwarden (Bitwarden) in Container Manager on a Synology NAS

Important or Recent Updates
Historic UpdatesDate
New Guide for Container Manager20/05/2023
Edited Argon2 / Admin Token Section as $$ in the hash are not required via the Container Manager UI22/05/2023
Adjusted the Reverse Proxy for WebSockets28/08/2023
Migrated the guide from the Container Manager UI to Projects as provides much easier updates as well as the added ability to use more docker compose variables such as the security amends.
Added additional security option to the compose to restrict the container from gaining new privileges, including the container running using our restricted docker user.
25/10/2023
Updated formatting of guide in line with the recent updates across the site
Fixed a regression in the guide in relation to the Argon2 hash (my apologies) and added the creation of the log folder as it is required.
04/11/2023
Removed port 3012 as no longer required for WebSocket notifications 04/02/2024
Historic Updates


What is Vaultwarden/Bitwarden?

Vaultwarden is a rewrite of the official Bitwarden server using the Rust language, it was created to reduce the need for the number of containers required for the official server.

It is compatible with all the official Bitwarden apps and Browser extensions. It 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
  • Part 2 — Setting up DDNS, Reverse Proxy and SSL
  • Part 3 — Setting up the Bitwarden Clients

Before we start head over to the short guides below to set up a restricted Docker user and Bridge Network.

Part 1 — Container Set up

Folder Setup

Let’s start by getting some folders set up for the containers to use. Open up File Station create the following.

Folders
/docker/projects/vaultwarden-compose
/docker/vaultwarden
/docker/vaultwarden/log

Container Manager

Next we are going to set up a ‘Project’ in Container Manager. Open up Container Manager and click on Project then on the right-hand side click ‘Create’.

In the next screen we will set up our General Settings.

SectionSetting
Project Name:vaultwarden
Path:/docker/projects/vaultwarden-compose
Source:Create docker-compose.yml

Next we are going to drop in our docker compose configuration, copy all the code in the box below and paste it into line ‘1’ just like the screenshot.

YAML
services:
  vaultwarden:
    image: vaultwarden/server:latest
    container_name: vaultwarden
    user: UID:GID #AMEND AS PER GUIDE
    environment:
      ROCKET_ENV: staging
      ROCKET_PORT: 8080
      ROCKET_WORKERS: 10
      SIGNUPS_ALLOWED: FALSE
      ADMIN_TOKEN: #YOUR ARGON ADMIN TOKEN
      LOG_FILE: /data/log/my.log
    volumes:
      - /volume1/docker/vaultwarden:/data
    ports:
      - 8122:8080/tcp
    network_mode: synobridge
    security_opt:
      - no-new-privileges:true
    restart: unless-stopped

Making some amendments

We need to make some amendments to the compose information above to secure our instance.

VariableValue
user: UID:GID
(line 5)
This line controls the user the container runs as we want to ensure it uses the dockerlimited user and group, amend the UID and GID to the ones you noted in the earlier set up guide.
ADMIN_TOKEN:
Line 11
As of version 1.28 of Vaultwarden it is recommended to create an Argon2 hashed admin token rather than using a plaintext one. We will be doing this via the Argon2 Hash Generator online if you wish to do this via SSH follow the instructions here.

Go to https://argon2.online/ and enter the variables in the table below into the form and then press ‘Generate Hash’.

OptionVariable to Select or Enter
Plain Text InputEnter either a long string of characters or a secure long ‘password’ you will use this to log in to your admin panel, so it needs to be secure, and you must remember it!
SaltPress the Cog it will generate a random string of characters
Parallelism Factor4
Memory Cost65540
Iterations3
Hash Length64
Three Argon VersionsSelect Argon2id

As you can see above we have generated our hash, however we need to make an adjustment to it otherwise it will not be valid for the compose.

If you see below the hash contains 5 occurrences of $ we need to escape these out by doubling them to $$

Example
Original
ADMIN_TOKEN: $argon2id$v=19$m=65540,t=3,p=4$QjdsUHBuUjVUd211RXJSRg$+z7E2XQ7GzBaIlvdvV/eC7GiWVgAVkwWDEkdtQNLmSl+BPsA/TUnxSNhb6bPZPY0vQM0wVGO9oiqz9VfT3EdKQ

Updated
ADMIN_TOKEN: $$argon2id$$v=19$$m=65540,t=3,p=4$$QjdsUHBuUjVUd211RXJSRg$$+z7E2XQ7GzBaIlvdvV/eC7GiWVgAVkwWDEkdtQNLmSl+BPsA/TUnxSNhb6bPZPY0vQM0wVGO9oiqz9VfT3EdKQ

Once you have made the edits and added into the correct line in the yaml you can click ‘Next’

You do not need to enable anything on the ‘Web portal settings’ screen click ‘Next’ again.

On the final screen click ‘Done’ which will begin the download of the container images and once downloaded they will be launched!

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.30:8122

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

Firewall Exceptions

(Skip if you don’t have the Firewall configured)

If you have the Synology Firewall enabled please see this additional guide for further info on exceptions and correct set up.

External Access

You have some choices when it comes to making your new container accessible from outside your home network, these come with different levels of security and convenience. This mini section is generic but covers the basics of getting this guide up and running and is entirely optional.

  • Synology’s DDNS (Dynamic Domain Name System) with a TLS Certificate and Reverse Proxy
    This is useful if you have some family members or friends that need access to something like Overseerr or Jellyseer and is covered below.

  • Tailscale or Wireguard VPN
    If just you are accessing these services, and you don’t want to expose them to the internet this would be the more secure choice. See my other separate guides.

  • Cloudflare Tunnels
    I don’t currently use these, so I would recommend watching the Wundertech guide on how they work.

A note on Double NAT or CGNAT
Unfortunately more ISPs are moving to these methods of address allocation as the IPv4 address space is getting low on available addresses. If your ISP is doing this your choices are more limited.

You can test if this is the case by checking the WAN IP on your Router/Modem settings and then comparing it to the one shown on portchecker.co. If they are different you are likely Double NAT and will either need to see if you can pay your ISP for a standard IPv4 address or use Tailscale or Cloudflare Tunnels for access.

Using the built-in tools on DSM

The first step of this process is to forward port 443 on your Router to your NAS IP Address, how you do this will depend on your router model, so please refer to its manual.

Router (External):443 > NASIP (Internal):443

Next 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/ If you already have this set up move to the next step.

DDNS (Dynamic Domain Name System)

A DDNS address allows you to get external access to your container via an address provided by Synology, this is useful on home internet connections where your ISP will change your IP address on a semi-regular basis.

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 will be the unique address just for you so keep the name generic.
minecraft.synology.me = BAD
myawesomenas.synology,me =GOOD
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

We are going to set up a reverse proxy subdomain for the address you just register. This means you and your users can access the container without using a port number as it will route all traffic through the secure 443 port.

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 or your users access the URL specified the request will automatically be sent to the containers web UI.

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

SettingValue
Reverse Proxy Name:Give it a meaningful name in line with the container you are setting up.
Protocol:HTTPS
Hostname:containername.xxx.synology.me
containername‘ will be the name you want to use to access this container
.xxx.synology.me‘ will be the exact name you registered earlier
Port:443
Protocol:HTTP
Hostname:‘localhost’ or your NAS IP address
Port:The UI Port Number from the yaml in the guide you are following

On the second tab ‘Custom Header’ click on Create then WebSocket, this will add two entries for WebSockets to function correctly, you can now press save.

You should now be able to access the web UI of the container by going to the address you just set up in the reverse proxy, it will be a secure connection, and you should have no certificate errors.

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.

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 which is the string of text or ‘password’ you used to create the Argon2 token (you don’t use the actual Argon2 string).

We need to change a few options to enable user sign up emails. (Please note that you will not be able to use Gmail SMTP in this step as they have disabled ‘unsecure’ 3rd party application login. Also, if you plan on using Yahoo you will need to set up an app specific password – as shown in this guide)

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

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.

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.

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 ‘Logging in on:’ and select ‘Self-hosted’

In the pop-up screen enter your full address for the server e.g. https://vaultwarden.xyz.synology.me

You have now completed the guide.

FAQ

Q) I am receiving the notice “You are using a plain text ADMIN_TOKEN which is insecure.”

A) A recent update changed the Admin Token used to access the admin panel to make it more secure. You can follow the next steps to migrate over.

  1. Follow the section of the guide to create the Argon2 token, you can use the existing ‘password’ aka admin token for this as it will still be used for the actual admin login screen, Important: when you get to the part that asks you to add the additional $ into the token skip that and come back here.
  2. Stop the Project and then edit the yaml and completely remove the existing ADMIN_TOKEN variable.
  3. Start the container again and login to the admin panel with your usual admin password. Scroll down to the bottom of the General Settings section and paste your Argon2 hash into the Admin token/Argon2 PHC option and save the settings.
  4. Restart the project again, and you will now be using the new hash and can log in with your usual password

How do I use GMAIL for SMTP?

Thanks to Dirtchamber Sessions for these steps

https://myaccount.google.com/apppasswords

You need to turn on 2FA in your Google account. At the bottom of the 2FA settings there is a section for App Password, create one and use that in the settings for your email password instead of your normal Gmail password.

Here are the settings that worked for me:

  • Host: smtp.gmail.com
  • Secure SMTP: starttls
  • Port: 587
  • From Address: username@gmail.com
  • Username: username@gmail.com
  • Password: your generated App Password from 2FA section of Google account
  • SMTP Auth mechanism: Plain
  • SMTP connection timeout: 15

Looking for some help, join our Discord community

If you are struggling with any steps in the guides or looking to branch out into other containers join our Discord community!

Buy me a beverage!

If you have found my site useful please consider pinging me a tip as it helps cover the cost of running things or just lets me stay hydrated. Plus 10% goes to the devs of the apps I do guides for every year.

Published inDockerOther Tools 7.2Synology

37 Comments

  1. james james

    what should you do if you have two synology nas.
    one is already using docker and ddns and forwarded to it.
    the other, has vaultwarden installed now, which i can use locally. however, wanting to use / access the web ui for admin.
    I am unable to as you can only forward one nas from router.
    i don’t even want to access both nas from outside LAN.
    it’s annoying that you have to open ports to the internet just to not have ssl certificates.
    thanks. appreciate your blog. James

    • Dr_Frankenstein Dr_Frankenstein

      Hey so I keep meaning to do something around SSL for internal use only without exposing to the Internet, it is possible with Tailscale but you can also cheat the Synology DDNS…

      Essentially after getting the SSL cert for the DDNS domain, change the external IP (on the section in the screenshot) to your NAS IP address. You can then close the port on your router and it should continue renewing the certificate. You would then use a VPN or Tailscale into your network to access it.

      https://drfrankenstein.co.uk/wp-content/uploads/2024/10/2024-10-31_20-32.jpg

      I have not tried this myself as I am using my own domains but have seen mention of this on Reddit.

  2. Marc Marc

    Hi,

    I’ll save you the trouble of having to respond to the previous issue.
    I tried it out with the admin UID and GID just to test it to see if it would work, which it did.
    Turned out to be that for some reason I hadn’t selected the “docker” folder to add as read/write permission for the docker group.
    Fixed that, working now.
    Hopefully helpful for someone else if they run into this, lol.

  3. Marc Marc

    Hi there,
    I’m trying to set up vault warden on another Synology NAS that I have but in contrast of the first one, the log indicates that it cannot write to the log file (data/log/my.log).
    Folders have been created upfront and everything else looks to be in order, but I keep having this issue.
    I’m using the UID and GID for the docker group, so I don’t think that is the issue.
    Can you point me in the right direction with this?

    Thanks

  4. Marcos Marcos

    Hi, I have it running just like the guide and I’ve tried to find my own answer however keep drawing up a blank. Vaultwarden works however it doesn’t work while remotely accessing it. I can go to all my ports on tailscale including the vault warden port. But when I try to use my hostname it has a connection timeout

  5. Matt Matt

    Any recommendations to make this work if you are behind CGNAT?
    I do have TwinGate setup on my synology but so far have had no luck in getting thos to work due to the CGNAT.

    • Dr_Frankenstein Dr_Frankenstein

      Hey sorry this ended up in Spam, Tailscale potentially for the external access, and then you can get SSL in place using the DDNS address from Synology but rather than use the ISP IP for its settings you can put the NAS IP

Leave a Reply

Your email address will not be published. Required fields are marked *

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!