this post was submitted on 05 Feb 2025
18 points (100.0% liked)

Selfhosted

41875 readers
891 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

  1. Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don't duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 2 years ago
MODERATORS
 

I'm trying to get Qbittorrent set up within Docker on my home server and want to configure port forwarding through my VPN for all of those Linux ISOs. Ideally, I also want to get a pipeline going with the *arr stack. I've heard the easiest way to do this is with Gluetun but I can't for the life of me figure it out or know how to test it. Anyone been through something similar?

Here is my current Docker Compose for reference:


services:
  gluetun:
    image: qmcgaw/gluetun:latest
    container_name: gluetun
    cap_add:
      - NET_ADMIN
    environment:
      - VPN_SERVICE_PROVIDER=airvpn
      - VPN_TYPE=wireguard
      - WIREGUARD_PRIVATE_KEY="[redacted]"
      - WIREGUARD_PRESHARED_KEY="[redacted]
      - WIREGUARD_ADDRESSES=10.131.184.14/32
      - FIREWALL_VPN_INPUT_PORTS=8069
      - SERVER_COUNTRIES=United States
    devices:
      - /dev/net/tun:/dev/net/tun
    volumes:
      - /home/fenndev/.config/gluetun:/config
    ports:
      - 9091:9091  # WebUI
     - 6881:6881
      - 6881:6881/udp
    restart: unless-stopped

qbit:
    image: lscr.io/linuxserver/qbittorrent:latest
    container_name: qbit
    network_mode: "service:gluetun"
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=America/Los_Angeles  # Timezone set to Los A>
      - WEBUI_PORT=9091  # Qbittorrent webUI port
    volumes:
      - /home/fenndev/.config/qbit:/config  # Configura>
      - /home/fenndev/torrents:/downloads  # Torrent da>
    depends_on:
      glueten:
        condition: service_healthy
top 8 comments
sorted by: hot top controversial new old
[–] [email protected] 1 points 1 day ago

Honestly, not sure. What you did looks close to what I'd expect reading the airvpn doc.

  1. Is port 6881 something unrelated? I think only local ports go there (e.g. your webui)

  2. obviously make sure you set the forwarded port in qbittorrent, then maybe try some external tool like ipleak.net which can give you a magnet link you can put in qbittorrent to see the reported geo location. Not sure if that perfectly vets the port you intend to use, though.

  3. glueten->gluetun in depends_on

If you attach to your docker as you launch, you might see some helpful output from either qbittorrent or gluetun (I think the "-it" flags

[–] [email protected] 4 points 2 days ago (2 children)

To enable port forwarding with gluetun see the port forwarding section in the gluetun wiki on their github page. It's pretty clear what you need to do there.

For port forwarding with qbit, gluetun's v3.40.0 release introduced an environment variable that allows the running of a script whenever the VPN changes port (see PR https://github.com/qdm12/gluetun/pull/2399). If you take a look at the PR some people shared commands to put under the env variable VPN_PORT_FORWARDING_UP_COMMAND.

So all you need to do is put that new environment variable in the environment section, take one of the example commands that uses the qbitorrent API to change the port when needed, and it should be all.

To test if port forwarding works qbittorrent will display a little green planet in the bottom bar, and if port forwarding is not working, a fire (to say it's firewalled).

[–] [email protected] 2 points 1 day ago (1 children)

Question: Does the green globe icon always indicate that it's working?

[–] [email protected] 1 points 1 day ago

Yes, if a port is set in the port forwarding section for the qbittorrent preferences in the webui (once one is set it stays until changed), the green globe means it's working.

[–] [email protected] 2 points 1 day ago (1 children)

allows the running of a script whenever the VPN changes port (see PR https://github.com/qdm12/gluetun/pull/2399).

That's an unknown, but welcome change. My experience for protonvpn was cludgy because you effectively had to run another service to spin and update qbittorrent's port whenever it changed. Happy to see some form of baked in support for it now.

[–] [email protected] 1 points 1 day ago

I was having a lot of trouble keeping port forwarding stable before this change with protonvpn too. Probably the best change I've seen with gluetun so far!

[–] [email protected] 1 points 2 days ago (1 children)

Typo in your network_mode of the qbit container?

[–] [email protected] 2 points 2 days ago

Sorry, I realized as I was pasting it that I had typo'd in my config (consistently, as in it was functional) and started to correct it. My bad.