How to correctly port forward through a vpn? (student dorm)

I am trying to get a node up and running while not being able to port forward through the local router because it is not mine. Thus, I am using Private Internet Access VPN which allows me to get a public open port (e.g. 50254). I use the gluetun docker image for this purpose and want to connect my storj docker to it using the " --net=container:gluetun" variable, which works fine.

The problem is the following: I am starting up my VPN container and then get assigned a random port. But because the storagenode container is using the network of the vpn container, I cannot use the “-p 50254:28967” variable which makes total sense. Is there an alternative way to route the random public port into the storj container that allows for port “remapping” in between?

Hope you can understand my problem :slight_smile:

1 Like

How is that?

Well no, not really. I want to use PIAs random port for storj. So i need to assign storj the random port. This tutorial is about accessing some services HTTP server, although the main traffic is using the VPN. I am already doing this to look at the localhost:14002 status page. This is different though. I am talking about the port thats usually 28967 and needs to be routed into the random port to reach the internet.

I kind of wanna use PIA and port forwarding like a reverse proxy. Similar to this:
but using docker and not a system wide VPN.

But you need to add some scripting to configure your ADDRESS environment variable with that port.
But it’s not a main problem. The main problem that you cannot use -p option to forward that port to the storagenode container, at least it would be useless.
You need to bind the storagenode to the<PIA_PORT>. You can do that in the config.yaml in the server.address: parameter or with the --server.address option, i.e.

storagenode run --identity-dir identity --config-dir config --server.address$(cat /tmp/gluetun/forwarded_PIA_port)

But you need to use a volume in the gluetun container and share it with the storagenode container and mount it to the /tmp/gluetun/forwarded_PIA_port.

It could work only if you inject storagenode to the gluetun container.
So, you need to build your own image.

There is not exactly working setup, just an idea:

FROM storjlabs/storagenode as addon
FROM qmcgaw/gluetun
COPY --from=addon /app/ /app/
COPY --from=addon /entrypoint /app/entrypoint
COPY ./ /
RUN chmod +x /

/entrypoint &
if [ -f ${PUBLICIP_FILE} ] && [ -f ${PORT_FORWARDING_STATUS_FILE} ]; then
    /app/entrypoint --server.address=$(cat ${PORT_FORWARDING_STATUS_FILE}) "$@"
elif [[ -z "`jobs`" ]]; then
    echo "gluetun died" 1>&2
    exit 1
    sleep 10


version: '3'
    image: gluetun-storagenode
    build: .
    container_name: storagenode
      - NET_ADMIN
      - OPENVPN_USER=js89ds7
      - OPENVPN_PASSWORD=8fd9s239G
      - REGION=AU Melbourne
      - WALLET=0x....
      - STORAGE=20TB
      - "14002:14002"
      - type: bind
        source: /mnt/storj/storagenode/identity
        destination: /app/identity
      - type: bind
        source: /mnt/storj/storagenode/
        destination: /app/config

Unfortunately the watchtower cannot update the custom build image.
To update you would need to do:

docker-compose build --pull
docker-compose up -d
1 Like