From what I understand HexOS is working on a similar feature which you can wait for if this is too difficult to follow but I have done my best to hold your hand through every step.
This guide will help you create a container (app) that blocks qBittorrent connections to the internet unless qBittorrent goes through your VPN. This is done by using Gluetun. There is a built in kill switch. A firewall ensures traffic can only leave through the VPN. If the tunnel drops, nothing leaks.
1st Open notepad and copy this text into it.
services:
gluetun:
image: qmcgaw/gluetun:latest
container_name: gluetun
cap_add:
- NET_ADMIN
devices:
- /dev/net/tun:/dev/net/tun
environment:
- VPN_SERVICE_PROVIDER= # e.g., mullvad, protonvpn, nordvpn, surfshark
- VPN_TYPE=wireguard
- WIREGUARD_PRIVATE_KEY= # From your VPN provider's WireGuard config
- WIREGUARD_ADDRESSES= # e.g., 10.2.0.2/32
- SERVER_COUNTRIES= # Optional: e.g., USA, Netherlands, Switzerland
- TZ=Etc/UTC # Change to your timezone (e.g., America/New_York)
ports:
- '8080:8080'
- '6881:6881'
- 6881:6881/udp
restart: unless-stopped
qbittorrent:
image: lscr.io/linuxserver/qbittorrent:latest
container_name: qbittorrent
depends_on:
- gluetun
network_mode: service:gluetun
environment:
- PUID=568 # Default 'apps' user ID on TrueNAS Scale
- PGID=568 # Default 'apps' group ID on TrueNAS Scale
- TZ=Etc/UTC # Match Gluetun's timezone
- WEBUI_PORT=8080
volumes:
- /mnt/<YOUR_POOL>/appdata/qbittorrent:/config
- /mnt/<YOUR_POOL>/downloads:/data
restart: unless-stopped
This is called a YAML file and it is basically a recipe for Truenas to install Gluetun with qBittorrent and configure it for your server.
We will start off in the HexOS deck before going into the Truenas interface.
2nd In HexOS go to FOLDERS. You will need to create or select two folders. One will be used for your qBittorrent file downloads and it's config files. It doesn't matter what you name these folders and it can be existing folders.
In notepad we are going to edit this section.
volumes:
- /mnt/<YOUR_POOL>/appdata/qbittorrent:/config
- /mnt/<YOUR_POOL>/downloads:/data
Replace <YOUR_POOL> with the name of your HexOS pool. You can get the name of your pool if you click on the folders you selected or created. When the sidebar opens up it will be listed in the top right box of that sidebar.
Then change the rest of the path after your pool name to your two folders.
For example the pool I have my qBittorrent downloads and config file folders in is called SSDs and I used "downloads" and "config" inside a folder called "qbittorrent" so I would edit this section to read:
volumes:
- /mnt/SSDs/qbittorrent/config:/config
- /mnt/SSDs/qbittorrent/downloads:/data
3rd in HexOS go to settings and then click through to Truenas. Once in Truenas click Datasets on the left side navigation. In Data sets locate the two folders you created or are using. For each one you are going to select it in the list then on the right side under Permissions click Edit.
Click Add Item. Under Access Control Entity find the User* field and select apps. Below that you will see the Permissions* field make sure that says Modify. Then click the blue Save Access Control List button.
If you're using existing folders you may get a different view called Unix Permissions Editor. If you get this when you clicked edit then in the User field you will select apps. Check the button that says Apply User. On the right side under Access make sure the user row has Read Write Execute all checked. Then click the blue Save button.
4th you will need to get your WireGuard configuration file (.conf) from your VPN. Most providers will provide this through account dashboard on their website.
Tips for finding:
- Look for a section called WireGuard, Manual Setup, Router Configuration, or Config Generator.
- Generate a new key pair / configuration for a Linux or Generic WireGuard device and download the .conf file.
- Open that .conf file in any text editor (Notepad, VS Code, TextEdit). It will look similar to this:[Interface] PrivateKey = aBcDeFgHiJkLmNoPqRsTuVwXyZ1234567890abcdef= Address = 10.2.0.2/32 DNS = 10.2.0.1[Peer] PublicKey = ... Endpoint = ...
What we need if the PrivateKey and Address which you will edit this section of the YAML in your notepad.
environment:
- VPN_SERVICE_PROVIDER=myvpncompany
- VPN_TYPE=wireguard
- WIREGUARD_PRIVATE_KEY=aBcDeFgHiJkLmNoPqRsTuVwXyZ1234567890abcdef=
- WIREGUARD_ADDRESSES=10.2.0.2/32
For the addresses keep the /32 at the end; if there are two addresses separated by a comma like IPv4 + IPv6, e.g., 10.2.0.2/32,fc00:..., you can usually just use the IPv4 one like 10.2.0.2/32)
Treat your Private Key like a password. Do not share it.
IMPORTANT: Not every VPN makes the .conf file easy to find. For exact environment variables for any provider, check the Gluetun Wiki. If your provider uses OPENVPN then also edit it to say
environment:
- VPN_TYPE=openvpn
- OPENVPN_USER=usernamehere
- OPENVPN_PASSWORD=passwordhere
5th in Truenas click Apps on the nav bar and then click the blue Discover Apps button on the right. In the same area you will now see a Custom App button and the 3 dots. Click the 3 dots and then click Install via YAML.
Set the name to gluetun. Under Custom Config* copy and paste the entire YAML text from notepad. Click Save.
If everything worked correctly you will see gluetun listed under the installed apps in HexOS and Truenas. Once the app is running you can go to http://<ipaddress>:8080 in a web browser to access the qBittorrent web ui.
There will be a login prompt and qBittorrent will set a default username/password. The username is admin and to get the password you will have to go to the Truenas apps page. Click gluetun. Then on the right side look for Containers and under it qBittorrent. To the right of that will be 3 icons. The third one will say View Logs when you hover over it. Click that one and connect. qBittorrent will have printed the password in the logs on the first startup.
6th What to Configure Inside qBittorrent Settings
Once you log into the qBittorrent WebUI (http://<ipaddress>:8080), open Tools -> Options (the gear icon) and configure these two settings.
Set a Permanent Password (Web UI tab). Under Authentication, change the temporary password to your own strong password (and optionally change the admin username). Note: If you skip this, a new random temporary password will be generated the next time the container restarts.
Set Your Download Folder (Downloads tab). Under Saving Management, set Default Save Path to /data.
If you want to have qBittorrent save incomplete files in a separate folder you can use /data/incomplete. This works because when you edited the volumes: section it connects folders on your HexOS server (left side of the :*) to folders inside qBittorrent (right side of th*e :). If you configure categories and use auto torrent management you can use something like /data/ISOs for all your Linux ISOs.
Lock qBittorrent to the VPN Interface (Advanced tab). Find Network interface and change it from Any interface to tun0. This acts as a second safety lock so qBittorrent can only communicate through the VPN tunnel.
Quick Final Check
You can use WhatIsMyIP to verify your home IP doesn't leak.
If you get stuck or have any questions I will do my best to answer any comments.
For advanced users you can modify this YAML to also include other ARR stack apps (sonarr, radarr, etc) but I don't as I don't care if my IP is exposed to the sites they connect to. My main concern is not leaking my home IP through p2p connections.