My Gluetun Setup#
This Gluetun setup runs in a Docker container using the official qmcgaw/gluetun image. It provides a secure VPN tunnel, supports HTTP proxy, and Shadowsocks for enhanced privacy.
My Docker Compose Configuration#
services:
gluetun:
container_name: gluetun # Container name
image: qmcgaw/gluetun # Gluetun image
cap_add:
- NET_ADMIN # Required to manage VPN networking
ports:
- 8888:8888/tcp # HTTP proxy
- 8388:8388/tcp # Shadowsocks
- 8388:8388/udp # Shadowsocks
volumes:
- ~/gluetun_vpn/config:/gluetun # Persistent Gluetun configuration
environment:
- HTTPPROXY=on # Enable built-in HTTP proxy
- VPN_SERVICE_PROVIDER=protonvpn # VPN provider name
- VPN_TYPE=wireguard # VPN protocol
- WIREGUARD_PRIVATE_KEY=your_private_key_here # WireGuard private key
- SERVER_COUNTRIES=Germany # VPN endpoint country filter
- PORT_FORWARD_ONLY=on # Require servers that support port forwarding
- VPN_PORT_FORWARDING=on # Enable VPN port forwarding
restart: unless-stopped # Restart unless stopped manually
Optional: Enable qBittorrent Port Forwarding#
Add this line to the environment section if you want Gluetun to update the qBittorrent listening port automatically:
- VPN_PORT_FORWARDING_UP_COMMAND=/bin/sh -c 'wget -O- --retry-connrefused --post-data "json={\"listen_port\":{{PORTS}}}" http://127.0.0.1:8443/api/v2/app/setPreferences 2>&1' # Push forwarded port to qBittorrent
Using Docker Secrets for Environment Variables#
You can set any environment variable from a file by using a special prepend FILE__.
For example:
FILE__MYVAR=/run/secrets/mysecretvariable