azinchen / nordvpn

NordVPN Docker Client
GNU Affero General Public License v3.0
95 stars 19 forks source link

Traefik, NordVPN, QBittorrent #248

Open maurocolella opened 1 year ago

maurocolella commented 1 year ago

Hi.

This is fantastic, but I am unable to access the qbittorrent web ui using a traefik subdomain.

version: "3"

services:
  qbittorrent:
    image: lscr.io/linuxserver/qbittorrent:latest
    container_name: qbittorrent
    environment:
      - TZ=Asia/Manila
      - WEBUI_PORT=7000
    volumes:
      - /var/data/qbittorrent/config:/config
      - <path>:/downloads
    restart: unless-stopped
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.qbittorrent.rule=Host(`qbittorrent.nas.home`)"
      - "traefik.http.services.qbittorrent.loadbalancer.server.port=7000"
      - "traefik.docker.network=nordvpn-2_default"
    network_mode: container:vpn2
version: "3"
services:
  nordvpn:
    image: azinchen/nordvpn:latest
    container_name: vpn2
    cap_add:
      - net_admin
    devices:
      - /dev/net/tun
    environment:
      - USER=
      - PASS=
      - RANDOM_TOP=10
      - RECREATE_VPN_CRON=5 */3 * * *
      - NETWORK=192.168.2.0/24
      - OPENVPN_OPTS=--mute-replay-warnings
    ports:
      - 7000:7000
      - 6881:6881
      - 6881:6881/udp
    restart: unless-stopped
gwest commented 1 year ago

I was having the same issue and solved it by moving the Traefik labels to the vpn container & also adding the network you use for Traefik to the vpn container under the networks property. e.g.

nordvpn:
    image: azinchen/nordvpn:latest
    container_name: vpn2
    networks:
      - {your network name}
    cap_add:
    ...
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.qbittorrent.rule=Host(`qbittorrent.nas.home`)"
      - "traefik.http.services.qbittorrent.loadbalancer.server.port=7000"
      - "traefik.docker.network=nordvpn-2_default"

I believe this will route the outbound traffic through the vpn, but still allow Traefik to route inbound web traffic through the vpn to the correct container, assuming you have the correct ports open on the vpn.

maurocolella commented 1 year ago

Thanks a lot gwest for the explanation, this seems to be it. It's also more of a general configuration matter with Traefik in this scenario, ie. containers need to be on the same network.