What is qBittorrent?#
qBittorrent is a awesome, simple app that allows you to use classic QBittorrent in a docker
container. I use QBittorrent because I can set it up with a VPN that only
connects via the container directly. Effectively separating it from the rest of
my network and allowing me to continue as normal while it is downloading. It
will automatically stop the network if the VPN is not functioning correctly.
Docker Compose Example#
########################################
# qbittorrentvpn - https://hub.docker.com/r/dyonr/qbittorrentvpn
# Client with WebUI that connects to OpenVPN with iptables killswitch to
# prevent IP leakage when the tunnel goes down
########################################
services:
qbittorrentvpn:
container_name: torrent
privileged: true
image: lscr.io/linuxserver/qbittorrent:latest
environment:
- PUID=1000
- PGID=1000
- VPN_ENABLED=false
- WEBUI_PORT=8080
- TZ=America/New_York
volumes:
- ${QBITTORRENT_DATA}/config:/config
- ${QBITTORRENT_DATA}/theme:/theme
- downloads_nfs:/downloads
restart: unless-stopped
network_mode: "container:gluetun"
volumes:
downloads_nfs:
name: downloads_nfs
driver_opts:
type: nfs
o: addr=${NAS_ADDR},nolock,soft,rw
device: :${DOWNLOADS_PATH}Gluetun Networking#
To ensure qBittorrent traffic is always protected by a VPN, I route its network through the gluetun container.
Enabling Gluetun Routing#
- Set Network Mode: In the qBittorrent service definition, add
network_mode: "container:gluetun". - Remove Ports: You must remove the
portssection from the qBittorrent service. All port mappings (like8080for the WebUI) must instead be defined in thegluetuncontainer’sportssection. - Local Access: Since the container is now in Gluetun’s network namespace, use Gluetun’s IP or the host’s IP to access the WebUI.
To set up the VPN you will need to have an existing account with a VPN service. Username & Password for the vpn will be provided as a key by your vpn service. In my case I use Surfshark and have to go log into my account, navigate to the linux setup page and grab my generated Username key and Password key there.
## download all availble server conf
sudo wget https://my.surfshark.com/vpn/api/v1/server/configurations
## cp the server you want to use into config folder
/app/QBittorrent/config/openvpnOnce you restart your qbittorrentvpn docker container you can test your vpn service with a torrent leak test. Use the + add torrent link button to Download the torrent and test that your VPN service is connected and working.
Magnet links#
Use magnet link and item hash to avoid logins
magnet:?xt=urn:btih:${HASH}