Skip to content

Deluge with OpenVPN in Docker on a Synology NAS

New guide09/03/2022
Amendment to VPN Server section to disable the server.10/03/2022
Updated the compose file with DNS settings to avoid potential connection issues12/03/2022
Added an example compose file to the FAQs showing how to add additional services to the VPN 21/03/2022
Tweaked Firewall section to take into account TCP VPN Providers05/07/2022

What are Deluge and OpenVPN?

Deluge is a lightweight torrent downloader, it has a number of built-in plugins to help organise your downloads and a full web interface, and OpenVPN is the client application used to connect to your VPN provider.

Let’s Begin

In this guide I will take you through the steps to get Deluge up and running in Docker and a separate OpenVPN container. By having a separate container for the VPN connection we can use it in the future for other applications such as Prowlarr, this is useful if you have torrent indexers blocked in your country.

As the Synology DSM GUI does not support some of the functions we need for this tutorial we will be using Docker Compose. This is not as complicated as it might seem!

In order for you to successfully use this guide please complete the two preceding guides

Folder Setup

Let’s start by getting a couple of folders set up for the containers to use. Open up Filestation and within the /docker share create a folder called ‘deluge’ and one called ‘vpn’

VPN Package / TUN Device

In a lot of guides you will see they require a script to run at the boot of the Diskstation in order to enable a TUN device. We are going to avoid this by using the Synology VPN Package, we won’t actually be using it, just using the TUN device it enables when turned on.

Head into the Package Center and download the Synology VPN Server package.

Once downloaded open up the VPN package and in the OpenVPN section enable the server.

Next click on Apply and you will receive this message regarding the Firewall and Router. We are not going to be forwarding any ports on our router, however if you do have the Firewall enabled on DSM we will be opening up an outbound port in a bit.

You can now disable the OpenVPN server by unchecking and applying the change again, as this has enabled the TUN, keep the package installed and running.

Firewall (Optional Step if you have the Firewall Enabled)

If you have the Synology Firewall enabled you will need to do this step. Otherwise, you will have issues with the VPN connecting to your provider.

Go into Control Panel > Security > Firewall

Click on Edit Rules and in the screen that appears click on ‘Create’

In the first screen select ‘Custom’

On the next screen we select the Type as ‘Destination Port’ and Protocol as ‘All’. In this example I am going to open up both 1194 and 1195 as some providers use UDP and some TCP and these are the most commonly used ports.

Click on OK and Apply the rule, and leave the ‘Source IP’ and ‘Action’ to their defaults on the original screen.

Configuration Files

In order for OpenVPN to connect to your provider we need to give it some key information for the connection. Due to the sheer amount of providers out there the information below will likely need to be tweaked based on your provider.

To keep this guide OS-agnostic I will be using the Synology Text Editor that can be installed via the package center. You can use your own preferred method such as using Notepad++ on Windows.

Open up Text Editor and create a new file, within this first file we are going to add our username and password for connecting to the VPN provider.

Now save this file in the ‘/docker/vpn’ folder and name it ‘vpn.auth’

The second file requires information from your VPN provider, they should have a number of OpenVPN configuration files for you to download on their website, usually split up into countries. Obtain one of these files.

Open up Text Editor and paste in the content of your providers .ovpn config file. It should look something like below. The Certificate section will not always be present if your provider gives you separate files for it.

We need to edit or add some key sections of this file as per the table below.

Original SettingUpdated SettingComments
auth-user-passauth-user-pass /vpn/vpn.authTells the container to get your login details from the vpn.auth file
persist-tun# persist-tunThis will ensure the connection is automatically reset if it fails
crl-verifycrl-verify /vpn/crl.rsa.2048.pemProvider Dependent – If you didn’t get a .pem file in with your config files you do not need to add this. If it is you need to ensure the crl.rsa.2048.pem is saved in the /docker/vpn folder
caca /vpn/ca.rsa.2048.crtProvider Dependent – If you didn’t get a .crt file you do not need to add this. If it is you need to ensure the ca.rsa.2048.crt is saved in the /docker/vpn folder

You can now save this file into ‘/docker/vpn’ named ‘vpn.conf’

If your provider uses certificate files these will also be saved here.

That’s the VPN settings done, let’s get onto the compose file.

Docker Compose

Next we are going to create a Docker Compose file, this is used to tell Docker how to set up our container with all the variables we require that are not available in the DSM GUI.

Open up Text Editor again and create a new file. Copy and paste the information below into the file.

version: "3.8"
    container_name: vpn
    image: dperson/openvpn-client:latest
      - net_admin # gives docker admin rights to amend network settings
      - /dev/net/tun #points to the tun device created by the syno VPN package
      - /volume1/docker/vpn:/vpn #The location of our config files
      - label:disable
      OPENVPN_OPTS: '--mute-replay-warnings'
      DNS: -- #this will override your default DNS and avoids connection issues you can change this value if you wish
    ports: #the port below allow the WebUI of any application connecting through the VPN to remain accessible locally
      - 8112:8112 # port for deluge - Add a line for each application you want to use the VPN
    command: '-f "" -r ""' # amend this in line with your local network settings
    restart: unless-stopped
    container_name: deluge
    network_mode: service:vpn # run on the vpn network
      - DELUGE_LOGLEVEL=error #optional
      - /volume1/docker/deluge:/config
      - /volume1/data/torrents:/data/torrents
      - vpn

You can change the formatting to YAML in the bottom right of the editor to make it easier to read.

We need to make some small amendments to the default settings to ensure they work for you.

ports(optional) If you want to run any other containers through the VPN connection you will need to add their WebUI port numbers to this section. By default we are just passing Deluge through. – If you do add something like Prowlarr you will need to move it to this compose file and then set its network mode in line with the one Deluge is using. (see the FAQ’s on Page 2)
command(required) in the command section you will see you will need to amend this in line with your local IPv4 settings for your network.
For example if the IP of your NAS is you will use or if your IP is you will use
network_mode (optional) You can see that the Deluge container is being told to use the VPN, if you added any other containers such as Prowlarr you will need to change their config in line with this. (See the FAQ’s on Page 2)
PUID(required) The UID you obtained in the user setup guide
PGID(required) The GID you obtained in the user setup guide
TZ(required) Your timezone
If you are having any issues with adding extra containers head over to Discord for some help

You can now save this compose file in /docker/vpn and call it delugevpn.yml

SSH and Docker-Compose

It’s time to get logged into you Diskstation via SSH, you can do this in the same way as when you obtained your IDs in the ‘Setting up a restricted Docker user‘ guide.

Once you have logged in you will need to give 2 commands, you can copy and paste these one at a time — you will need to enter your password for the command starting with ‘sudo’

First we are going to change directory to where the delugevpn.yml is located, type the below and then press enter.

cd /volume1/docker/vpn

Then we are going to instruct Docker Compose to read the file we created and complete the set-up of the container. Again type the below and press enter.

sudo docker-compose -f delugevpn.yml up -d

When the command has completed you should be able to see both Deluge and the VPN container running in the list of containers in the Synology GUI.

Final steps

As we have used /data/torrents as the mount point for our downloads we need to make sure Deluge uses this same file path.

We are going to do this by just changing the directory settings within Deluge.

Open a new browser tab and go to your NAS IP address on port 8112 (e.g

Deluge by default has the password of ‘deluge’ to access the web UI, you can change or remove this later in the settings.

Next you will connect to the Deluge back end, just select the host and click connect, it will remember this going forward.

Now you are in the UI click on Preferences at the top of the screen, we are going to change the various folders to the settings shown in the screenshot/table below

Download to:/root/Downloads/data/torrents/incoming
Move complete to:/root/Downloads/data/torrents/completed


There are a couple of plugins you will want to enable.

  • Autoadd – This allows you to pull in any torrents in the watch directory
  • Label – This allows Radarr/Sonarr to assigned labels and pull downloads into subdirectories – no additional configuration required for this plugin
  • Auto Remove Plus – Download the ‘AutoRemovePlus-2.0.0-py3.8.egg’ version from the Deluge forums and place it in the Plugins’ folder in /docker/deluge/plugins. It allows you to fine tune when to remove torrents and their associated data once downloaded. (You may need to stop and re-up the container for this to appear)
Autoadd Plugin Settings
AutoremovePlus Settings

That’s it you are completely set up!

FAQs – See Page 2 of this guide

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 inDockerDownload ToolsSynology


  1. Louis Didier Louis Didier

    Is there a way I can check if the vpn login successfully. The vpn container is up and running but I just want to be sure that the vpn is covering the torrents. Thank you

    • Dr_Frankenstein Dr_Frankenstein

      Hey I will update the FAQ,  You can use this to double check, it will display the ip it sees

      Also Deluge shows the IP in the bottom right of the UI it will be the one from your VPN.

  2. Phil Phil

    Thanks a lot for creating this manual. Setting up deluge+VPN in docker worked fine with cyberghost VPN.
    my issue: My DS920+ is set up to shut down between 11pm and 8am. When it starts up again, I get the error messages “Docker container vpn stopped unexpectedly. Please select vpn on the Container page, click the Details button, and go to the Log tab for details.“
    Any advice how to debug? (first time NAS user here :))

    • Dr_Frankenstein Dr_Frankenstein

      Hey Phil – Are you then able to bring the container back up again manually using the Docker Compose or does it also give you an error?

      • Phil Phil

        thanks for the answer!

        I think I can bring up the VPN container manually. It shows “running” and the last entry in the log is “Initialization Sequence Completed”
        (okay, while writing, I got the message that the container stopped unexpectedly. But it seems to start automatically, and the “Initialization Sequence Completed” entry is again the last one in the list.)

        When I want to start the deluge container manually afterwards, it says “Container must join at least one network”

        • Dr_Frankenstein Dr_Frankenstein

          The containers should come back up successfully from a reboot or cold shutdown. To bring them up manually you have to run the docker compose file as the Syno Docker UI doesn’t understand the command used that gets Deluge to use the VPN containers network.
          This might take a bit more investigation as I suspect even though the container has reported it being up (VPN) it hasn’t actually connected yet. The depends_on variable in the compose tells Deluge to wait until it receives a signal that the VPN container has booted, however I think it may be stopping as it cannot actually see a connection, this is just a theory!

        • Dr_Frankenstein Dr_Frankenstein

          I think I may have a solution for you, and It’s something I could then build into the FAQ

          Can you jump on Discord or ping me an email

  3. Stevvy Stevvy

    Thanks for write up and guide. I only have one problem, at the docker screen it shows deluge “Running” but vpn is switching every few seconds between “Running” and “Restarting”. Any ideas why?

    • Stevvy Stevvy

      Also already have 18 notifications within 2 minutes stating “Docker container vpn stopped unexpectedly” also can’t access the 8112 port

      • Dr_Frankenstein Dr_Frankenstein

        Hey, this will be due to the VPN not being able to connect, so it will just loop.

        Are you able to reach out either via Discord or via the contact page, so we can take a look at the logs? You can just stop the VPN container for the moment.

      • Dr_Frankenstein Dr_Frankenstein

        Hey Stevvy, sorry I completely missed this comment so very late in replying – Did you get it working? if not feel free to reach out on Discord or via the contact page as we can get you running fairly quickly!

    • Dr_Frankenstein Dr_Frankenstein

      Hey Stevvy, sorry I completely missed this comment so very late in replying – Did you get it working? if not feel free to reach out on Discord or via the contact page as we can get you running fairly quickly!

  4. JDog JDog

    Great article. Maybe this will help someone else, but I was getting “Connection reset” messages back in my browser for containers that were configured using “network_mode: service:vpn”.

    It wasn’t until I changed it to “network_mode: container:vpn” that they were reachable.

    • Dr_Frankenstein Dr_Frankenstein

      Hey, it’s odd that you had to change that setting, make sure the container is actually using your VPN connection by using the test I have added to the FAQ on page 2 of the guide.

  5. Chris Chris

    I have vpn and deluge running successfully. However, I kept getting operation not permitted error under tracker status

    • Dr_Frankenstein Dr_Frankenstein

      This could be a file permissions issue can you double check your PUID and PGID and make sure they are the right way around

      • Chris Chris

        checked and PUID and PGID are correct. Any other ideas?

        • Dr_Frankenstein Dr_Frankenstein

          Has your VPN connected successfully? Could you jump on Discord so we can troubleshoot, it will be easier than in the comments.

          • Chris Chris

            You are correct. it was VPN issue. Have VPN connected successfully and problem solved. Thanks.

          • Dr_Frankenstein Dr_Frankenstein

            Good stuff

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed. – writing Synology Docker Guides since 2016 – Join My Discord!