|
|
||
|---|---|---|
| docs | ||
| .env.example | ||
| .gitignore | ||
| classifier.yml | ||
| docker-compose.yaml | ||
| README.md | ||
tunnelled-torrents
Docker Compose stack that runs Bitmagnet (DHT crawler + torrent index) and qBittorrent with all of their traffic forced through a ProtonVPN WireGuard tunnel via gluetun. If the VPN container stops, the other two lose their network entirely — they have no route to the internet that bypasses it.
Architecture
host
│
┌────────────┴─────────────┐
│ vpn (gluetun) │◄── publishes ALL host ports
│ ProtonVPN / WireGuard │ 3333 3334 8080 6881 8778 8001
│ ─── network namespace ──┤
│ bitmagnet qbittorrent│ network_mode: container:vpn
└────────────┬─────────────┘
│ bitmagnet_net (bridge)
┌──────┴───────┐
│ postgres │
└──────────────┘
vpn owns the network namespace. bitmagnet and qbittorrent join it with
network_mode: "container:vpn" — they have no network stack of their own, they are the VPN
container's stack. postgres stays on the normal bitmagnet_net bridge.
Two gotchas this layout forces
- Ports for bitmagnet and qbittorrent must be declared on the
vpnservice. Aports:block on a service usingnetwork_mode: container:...is rejected/ignored by Docker — there is no namespace of its own to bind in. That is why thevpnservice publishes 3333, 3334, 8080 and 6881 even though it doesn't listen on any of them itself. postgresneeds the explicitnetworks: [default]block. Bitmagnet reaches the database at hostnamepostgresthrough the VPN container's namespace, so the bridge network must exist and be joined explicitly rather than left implicit.
Ordering is handled by depends_on: { vpn: { condition: service_healthy } } — nothing starts
until gluetun reports the tunnel is up, so there is no window where traffic leaks.
Ports
| Host | Container | Service |
|---|---|---|
| 3333 | 3333 | Bitmagnet API + Web UI |
| 3334 | 3334 tcp+udp | Bitmagnet BitTorrent / DHT |
| 8080 | 8080 | qBittorrent Web UI |
| 6881 | 6881 tcp+udp | qBittorrent incoming torrent traffic |
| 8778 | 8888 | gluetun HTTP proxy |
| 8001 | 8000 | gluetun control server (API key required) |
Setup
cp .env.example .env
$EDITOR .env # WireGuard key + address, TMDB key, downloads path
docker compose up -d
.env.example documents where each value comes from. .env is gitignored.
The stack creates gluetun/, config/, data/postgres/ and qbittorrent/config/ on first run;
all four are gitignored runtime state.
Web UIs: Bitmagnet on http://localhost:3333, qBittorrent on http://localhost:8080.
Verify the tunnel
The single most important check — this must print the ProtonVPN exit IP, never your ISP's:
docker compose exec -it bitmagnet wget -qO- https://ipinfo.io
Run it after any change to the vpn service. Same check works for qbittorrent.
Gluetun's own view of the tunnel, including the forwarded port:
curl -H "X-API-Key: $HTTP_CONTROL_SERVER_SECRET_KEY" http://localhost:8001/v1/openvpn/portforwarded
ProtonVPN's forwarded port changes; PORT_FORWARD_ONLY=on means gluetun will only connect to
servers that support port forwarding. Paste the reported port into qBittorrent's
Settings → Connection → Port used for incoming connections to get connectable status.
Files
| Path | Purpose |
|---|---|
docker-compose.yaml |
The stack |
.env.example |
Every variable the compose file needs |
classifier.yml |
Bitmagnet classifier rules (currently a keyword-delete example; not mounted — uncomment the volume line in docker-compose.yaml to enable) |
docs/docker-compose.pre-vpn.yaml |
The pre-gluetun layout, kept for reference |
Live deployment
The running instance is deployed out of /home/yippee/Bitmagnet on this host, where the secrets
sit inline in the compose file rather than in a .env. Changes made there are not picked up
here automatically — port changes, new services or image bumps need copying back into this repo.