MarkusMcNugen / docker-qBittorrentvpn

Docker container which runs a headless qBittorrent client with WebUI and optional OpenVPN
https://hub.docker.com/r/markusmcnugen/qbittorrentvpn/
GNU General Public License v3.0
177 stars 90 forks source link

Restart on VPN problem, support PIA port forwarding #96

Open Tailslide opened 3 years ago

Tailslide commented 3 years ago

Addresses Issues #60 and #88

Sample Compose.yml

Here is a sample compose file I am using to run this. These settings allow tunnel access and also auto restart the container since these changes cause the container to exit if the VPN becomes unresponsive or the client crashes:

    devices:
      - /dev/net/tun
    cap_add:
      - NET_ADMIN
    restart: always

New environment variable is PIA_PORT_FORWARD that handles port forwarding on PIA servers that have this feature enabled.

version: '3.4'

services:
  dockerqbittorrentvpn:
    image: tailslide/dockerqbittorrentvpn:latest
    environment:
      - VPN_ENABLED=yes
      - PIA_PORT_FORWARD=yes
      - PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
      - NAME_SERVERS=8.8.8.8,8.8.4.4
      - LAN_NETWORK=192.168.12.0/24
      - TZ=Canada/Mountain
      - DEBIAN_FRONTEND=noninteractive
    ports:
      - "8080:8080"
    devices:
      - /dev/net/tun
    cap_add:
      - NET_ADMIN
    restart: always
    volumes: 
      - /volume1/IncomingTV:/IncomingTV
      - /volume1/temp:/temp
      - /volume1/torrents:/torrents
      - /volume1/docker/qbittorrent:/config
    networks:
      - torrent
networks:
  torrent:
    external: true

Sample output

[info] PIA Port forwarding configured, calling pia_port_forwarding.sh
Starting script
getting token
6b6d303509d68b8f11c8a77dc72ad58581c48900f7aea5ed52d58a18504de6aaa9d006a19d61d7e666a96136f4f71a7b9eff0eb343da8e839cce9b0330de273ef
done getting token
starting port forwarding check
Tue May 25 09:37:22 MDT 2021: Getting PF token
Tue May 25 09:37:22 MDT 2021: Obtained PF token. Expires at 2021-07-27T03:38:33.079193308Z
Tue May 25 09:37:23 MDT 2021: Server accepted PF bind
Tue May 25 09:37:23 MDT 2021: Forwarding on port 36290
Current Port: 32761
pia-port: Current port forward: 32761
pia-port: New port number (36290) inserted into config file /config/qBittorrent/config/qBittorrent.conf.
Logging to /config/qBittorrent/data/logs/qbittorrent-daemon.log.
2021-05-25 09:37:31.520319 [info] Started qBittorrent daemon successfully...
Tue May 25 09:37:31 MDT 2021: Rebind interval: 900 seconds
Tailslide commented 3 years ago

Needs some work