Complete installation guide for Torrent VPN Stack on Linux distributions.
- OS: Ubuntu 20.04+, Debian 11+, Fedora 35+, Arch Linux, or other modern Linux distributions
- RAM: 2 GB minimum, 4 GB recommended
- Disk: 10 GB free space minimum
- CPU: 64-bit processor
- Docker Engine (20.10+)
- Docker Compose v2 (included with Docker Engine)
- Git
- Bash (4.0+)
# Update package index
sudo apt update
# Install dependencies
sudo apt install -y ca-certificates curl gnupg
# Add Docker's official GPG key
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
# Add Docker repository
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Install Docker Engine
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# Add user to docker group (avoids needing sudo)
sudo usermod -aG docker $USER
# Log out and back in for group changes to take effect# Check Docker version
docker --version
docker compose version
# Test Docker (may require logout/login first)
docker run hello-world# Remove old Docker versions
sudo dnf remove docker docker-client docker-client-latest docker-common \
docker-latest docker-latest-logrotate docker-logrotate docker-selinux \
docker-engine-selinux docker-engine
# Install Docker repository
sudo dnf -y install dnf-plugins-core
sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
# Install Docker Engine
sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# Start and enable Docker
sudo systemctl start docker
sudo systemctl enable docker
# Add user to docker group
sudo usermod -aG docker $USER
# Log out and back in for group changes to take effect# Install Docker
sudo pacman -Syu docker docker-compose
# Start and enable Docker
sudo systemctl start docker.service
sudo systemctl enable docker.service
# Add user to docker group
sudo usermod -aG docker $USER
# Log out and back incd ~
git clone https://github.com/ddmoney420/torrent-vpn-stack.git
cd torrent-vpn-stack# Make scripts executable
chmod +x scripts/*.sh
# Run setup wizard
./scripts/setup.shThe wizard will guide you through:
- VPN provider selection and credentials
- Network configuration
- Downloads directory setup
- Optional features (port forwarding, monitoring)
# Basic stack (VPN + qBittorrent)
docker compose up -d
# With port forwarding (ProtonVPN Plus, PIA)
docker compose --profile port-forwarding up -d
# With monitoring (Prometheus + Grafana)
docker compose --profile monitoring up -d
# All features
docker compose --profile port-forwarding --profile monitoring up -d./scripts/verify-vpn.shExpected output:
✓ VPN connection active
✓ IP address: 123.45.67.89 (VPN provider IP)
✓ DNS leak test: PASSED
The Linux version supports both systemd timers (preferred) and cron (fallback).
# Set up daily backups at 3 AM (runs as your user, no sudo needed)
./scripts/setup-backup-automation-linux.sh
# Customize schedule
./scripts/setup-backup-automation-linux.sh --hour 2 --retention 14# View timer status
systemctl --user status torrent-vpn-backup.timer
# Check next run time
systemctl --user list-timers torrent-vpn-backup.timer
# Run backup manually
systemctl --user start torrent-vpn-backup.service
# View logs
journalctl --user -u torrent-vpn-backup.service
# Disable automation
./scripts/remove-backup-automation-linux.shIf systemd is not available:
# Set up cron job
./scripts/setup-backup-automation-linux.sh --method cron
# Verify cron job
crontab -l# Run backup manually
./scripts/backup.sh
# Custom backup location
BACKUP_DIR=~/my-backups ./scripts/backup.sh
# Keep backups for 14 days
BACKUP_RETENTION_DAYS=14 ./scripts/backup.shAll services are accessible at localhost or your server IP:
-
qBittorrent Web UI: http://localhost:8080
- Default credentials:
admin/adminpass(change in.env)
- Default credentials:
-
Grafana (if monitoring enabled): http://localhost:3000
- Default credentials:
admin/admin
- Default credentials:
-
Prometheus (if monitoring enabled): http://localhost:9090
If using UFW firewall:
# Allow qBittorrent WebUI (from local network only)
sudo ufw allow from 192.168.1.0/24 to any port 8080
# Allow Grafana (optional)
sudo ufw allow 3000/tcp
# Reload firewall
sudo ufw reload# Allow qBittorrent WebUI
sudo firewall-cmd --permanent --add-port=8080/tcp
# Allow Grafana (optional)
sudo firewall-cmd --permanent --add-port=3000/tcp
# Reload firewall
sudo firewall-cmd --reloadTo start the stack automatically on boot:
Create /etc/systemd/system/torrent-vpn-stack.service:
[Unit]
Description=Torrent VPN Stack
Requires=docker.service
After=docker.service
[Service]
Type=oneshot
RemainAfterExit=yes
WorkingDirectory=/home/YOUR_USERNAME/torrent-vpn-stack
ExecStart=/usr/bin/docker compose --profile port-forwarding up -d
ExecStop=/usr/bin/docker compose down
User=YOUR_USERNAME
Group=YOUR_USERNAME
[Install]
WantedBy=multi-user.targetReplace YOUR_USERNAME with your actual username.
# Reload systemd
sudo systemctl daemon-reload
# Enable on boot
sudo systemctl enable torrent-vpn-stack.service
# Start now
sudo systemctl start torrent-vpn-stack.service
# Check status
sudo systemctl status torrent-vpn-stack.serviceError: permission denied while trying to connect to the Docker daemon
Solution:
# Add user to docker group
sudo usermod -aG docker $USER
# Log out and back in, OR run:
newgrp docker
# Verify
docker psError: Gluetun container constantly restarting
Solutions:
-
Check VPN credentials in
.env:cat .env | grep VPN -
View Gluetun logs:
docker logs gluetun
-
Verify VPN provider configuration:
-
Test network connectivity:
docker exec gluetun ping -c 3 8.8.8.8
Error: localhost:8080 not accessible
Solutions:
-
Verify containers are running:
docker ps
-
Check
LOCAL_SUBNETin.envmatches your network:ip addr show | grep inet # Update LOCAL_SUBNET in .env accordingly
-
Check firewall rules:
# UFW sudo ufw status # firewalld sudo firewall-cmd --list-all
-
Restart stack:
docker compose down docker compose up -d
-
"Unauthorized" error instead of login page:
# Stop qBittorrent docker compose stop qbittorrent # Disable host header validation docker run --rm -v torrent-vpn-stack_qbittorrent-config:/config alpine sh -c ' echo "WebUI\HostHeaderValidation=false" >> /config/qBittorrent/qBittorrent.conf' # Restart docker compose start qbittorrent
Error: Volume mount fails or "path not found"
Solution: Use absolute paths in .env (tilde ~ expansion may fail):
# Wrong:
DOWNLOADS_PATH=~/Downloads/torrents
# Correct:
DOWNLOADS_PATH=/home/yourusername/Downloads/torrentsError: No forwarded port assigned
Solutions:
-
Verify your VPN provider supports port forwarding:
- ✅ ProtonVPN Plus, PIA
- ❌ Mullvad (discontinued July 2023), NordVPN, Surfshark, ExpressVPN
-
Enable port forwarding profile:
docker compose --profile port-forwarding up -d
-
For ProtonVPN, ensure
.envhas:VPN_PORT_FORWARDING_PROVIDER=protonvpn -
Check port sync logs:
docker logs gluetun-qbittorrent-sync
Error: Backups not running automatically
Solutions:
-
Check timer status:
systemctl --user status torrent-vpn-backup.timer
-
Enable linger (allows user services to run when not logged in):
sudo loginctl enable-linger $USER -
View service logs:
journalctl --user -u torrent-vpn-backup.service -n 50
Edit /etc/docker/daemon.json:
{
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "3"
},
"storage-driver": "overlay2"
}Restart Docker:
sudo systemctl restart docker# Increase file descriptor limits
echo "fs.file-max = 100000" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
# Optimize network settings
echo "net.core.rmem_max = 134217728" | sudo tee -a /etc/sysctl.conf
echo "net.core.wmem_max = 134217728" | sudo tee -a /etc/sysctl.conf
sudo sysctl -pSee Performance Tuning Guide for more optimizations.
# Stop and remove containers
docker compose down
# Remove volumes (WARNING: deletes all data)
docker volume rm torrent-vpn-stack_gluetun-config torrent-vpn-stack_qbittorrent-config
# Remove images (optional)
docker image rm qmcgaw/gluetun linuxserver/qbittorrent# systemd
./scripts/remove-backup-automation-linux.sh --method systemd
# cron
./scripts/remove-backup-automation-linux.sh --method cron
# Both
./scripts/remove-backup-automation-linux.shUbuntu/Debian:
sudo apt purge docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo rm -rf /var/lib/docker /var/lib/containerdFedora:
sudo dnf remove docker-ce docker-ce-cli containerd.io
sudo rm -rf /var/lib/docker /var/lib/containerd- Configure VPN Provider
- Set Up Port Forwarding
- Enable Monitoring
- Performance Tuning
- Backup and Restore