thrnz / docker-wireguard-pia

A Docker container for using Wireguard with PIA.
269 stars 53 forks source link

unclear how to config deluge port forwarding #16

Open rthidfrev opened 3 years ago

rthidfrev commented 3 years ago

I have wireguard-pia and deluge working fine, but I don't upload, I think I misconfigured my compose docker, I'm a beginner and I'm lost, can somebody help me pls. ty !

#===============================================================================
#=============================== V.2.0 =========================================
#===============================================================================
version: '3.7'
services:
#===============================================================================
    vpn:
        image: thrnz/docker-wireguard-pia
        container_name: vpn
        volumes:
            - ${ROOT}/pia:/pia
            - ${ROOT}/pia-shared:/pia-shared
        cap_add:
            - NET_ADMIN
            - SYS_MODULE
        environment:
            - LOC=swiss
            - USER=pxxxxxxxx
            - "PASS=xxxxxxxxx"
            #- LOCAL_NETWORK=192.168.1.0/24
            #- KEEPALIVE=25
            #- VPNDNS=8.8.8.8,8.8.4.4
            - PORT_FORWARDING=1
            #- WG_USERSPACE=1
        sysctls:
            # wg-quick fails to set this without --privileged, so set it here instead if needed
            - net.ipv4.conf.all.src_valid_mark=1
            # May as well disable ipv6. Should be blocked anyway.
            - net.ipv6.conf.default.disable_ipv6=1
            - net.ipv6.conf.all.disable_ipv6=1
            - net.ipv6.conf.lo.disable_ipv6=1
        # The container has no recovery logic. Use a healthcheck to catch disconnects.
        healthcheck:
            test: ping -c 1 www.google.com || exit 1
            interval: 30s
            timeout: 10s
            retries: 3
        ports:
            - 9111:9000 # portainer.io
            - 9983:80 # Organizrr
            - 4545:4545
            - 6767:6767
            - 6789:6789
            - 8989:8989
            - 7878:7878      
            - 3579:3579
            - 8112:8112 # Deluge
#===============================================================================
    deluge:
        container_name: deluge
        image: linuxserver/deluge:latest
        restart: always
        network_mode: service:vpn 
        depends_on:
          - vpn    
        environment:
          - PUID=${PUID} 
          - PGID=${PGID} 
          - TZ=${TZ} 
        volumes:
          - ${ROOT}/downloads:/downloads 
          - ${ROOT}/config/deluge:/config 
#===============================================================================
    deluge-port-helper:
        container_name: deluge_port_forwarding
        build: /media/homemedia/pia/pia
        volumes:
            - ${ROOT}/pia-shared:/pia-shared
            - ${ROOT}/config/deluge:/config 
        network_mode: "service:vpn"
        depends_on:
            - vpn
            - deluge
rthidfrev commented 3 years ago

1 Capture du 2021-01-31 13-44-32

thrnz commented 3 years ago

I'm no longer using Deluge, but if you're using this example helper container as-is, then it expects the config to be mounted at /deluge/config rather than /config. So:

    deluge-port-helper:
        container_name: deluge_port_forwarding
        build: /media/homemedia/pia/pia
        volumes:
            - ${ROOT}/pia-shared:/pia-shared
            - ${ROOT}/config/deluge:/deluge/config
        network_mode: "service:vpn"
        depends_on:
            - vpn
            - deluge

From memory, using deluge-console was a bit unstable at times, so it might need some retry logic added if something unexpected happens.

Alternatively, if you're not having much luck scripting it, you can set the env var PORT_PERSIST=1 on the vpn container, and then just enter the forwarded port manually into Deluge. IIRC PIA will give the same forwarded port number for two months if done this way.

P8ntBal1551 commented 3 years ago

I got port forwarding to work by a work-around hacky solution

  1. mount your deluge config directory to /pia-shared in the wireguard container so that it can write port.dat into that folder
  2. map a volume at /pia in the deluge container, doesn't matter if it's a volume or a bind point
  3. turn on both the wireguard and deluge containers
  4. in the deluge container run ln -s /config/port.dat /pia/forwarded_port
  5. install this addon into deluge https://github.com/jawilson/deluge-piaportplugin

it should just work after that, no need for another container

rthidfrev commented 3 years ago

huge, ty !

thrnz commented 3 years ago

I've just added the option to set where the forwarded port number gets dumped to. That way you can set PORT_FILE=/path/to/forwarded_port and then mount it into both containers as-is without needing to use symlinks. Should make things a tad simpler.