Skip to content

Commit

Permalink
add example for proton vpn port forwarding setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Splinter7914 committed Dec 31, 2024
1 parent ee041f3 commit 3da4f5e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
22 changes: 22 additions & 0 deletions setup/advanced/scripts/qbittorrent-port-updater.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh

LISTEN_PORT="$1"
QBIT_PROTOCOL="${QBIT_PROTOCOL:-http}"
QBIT_HOST="${QBIT_HOST:-127.0.0.1}"
QBIT_PORT="${QBIT_PORT:-8080}"

# add curl if not already installed
apk info | grep -q ^curl || apk add curl

# syntax specific to sh
for run in $(seq 1 10)
do
echo "Try $run/10 to set port to $LISTEN_PORT"
curl -ks --data 'json={"listen_port": "'"$LISTEN_PORT"'"}' ${QBIT_PROTOCOL}://${QBIT_HOST}:${QBIT_PORT}/api/v2/app/setPreferences
if [ $? -eq 0 ]; then
echo "Port $LISTEN_PORT set successfully"
break
fi
echo "Failed to set port, retrying in 5 seconds"
sleep 5
done
9 changes: 9 additions & 0 deletions setup/advanced/vpn-port-forwarding.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ Notes:
- one can bind mount a shell script in Gluetun and execute it with for example `VPN_PORT_FORWARDING_UP_COMMAND=/bin/sh -c /gluetun/myscript.sh` - 💁 feel free to propose a pull request to add commonly used shell scripts for port forwarding!
- the output of the command is written to the port forwarding logger within Gluetun

### qBittorrent Example

See [qbittorrent-port-updater.sh](scripts/qbittorrent-port-updater.sh) for an example of how this can be done. Add a bind mount to this script and then refert to it: `VPN_PORT_FORWARDING_UP_COMMAND=/bin/sh -c "/tmp/qbit-port-updater.sh {{PORTS}}"`

Notes:

- In order to get the call working make sure port qBittorrent is listening on is open. For example `- 8080:8080` to the ports definition. Without this calls do not go through.
- Add `127.0.0.1/32` to bypass authentication settings for qBittorrent.

## Allow a forwarded port through the firewall

For non-native integrations where you have a designated forwarded port from your VPN provider, you can allow it by adding it to the environment variable `FIREWALL_VPN_INPUT_PORTS`.
Expand Down
3 changes: 2 additions & 1 deletion setup/providers/protonvpn.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ services:
- SERVER_COUNTRIES=Netherlands
```
💁 To use with Wireguard, download a configuration file from [account.proton.me/u/0/vpn/WireGuard](https://account.proton.me/u/0/vpn/WireGuard) and head to [the custom provider Wireguard section](custom.md#wireguard). Thanks to [@pvanryn](https://github.com/pvanryn) for pointing this out. Note however you cannot filter servers as easily as with OpenVPN since each server uses its own private key and/or peer address.
💁 To use with Wireguard, download a configuration file from [account.proton.me/u/0/vpn/WireGuard](https://account.proton.me/u/0/vpn/WireGuard) and set the `WIREGUARD_PRIVATE_KEY`. You can do a [the custom provider Wireguard section](custom.md#wireguard) to pick a specific server. Thanks to [@pvanryn](https://github.com/pvanryn) for pointing this out.

## Required environment variables

Expand Down Expand Up @@ -75,6 +75,7 @@ Requirements:
- Add `+pmp` to your OpenVPN username (thanks to [@mortimr](https://github.com/qdm12/gluetun/issues/1760#issuecomment-1669518288))
- `VPN_PORT_FORWARDING=on`
- If you use **Wireguard** using the custom provider, set `VPN_PORT_FORWARDING_PROVIDER=protonvpn`
- See [custom port forwarding updown command](advanced/vpn-port-forwarding.md#custom-port-forwarding-updown-command) for examples of how to automate this.

## Multi hop regions

Expand Down

0 comments on commit 3da4f5e

Please sign in to comment.