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?
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.
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 0.0.0.0:<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 0.0.0.0:$(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: Dockerfile:
FROM storjlabs/storagenode as addon
FROM qmcgaw/gluetun
COPY --from=addon /app/ /app/
COPY --from=addon /entrypoint /app/entrypoint
COPY ./entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
WORKDIR /app
ENTRYPOINT ["/entrypoint.sh"]
entrypoint.sh
#!/bin/sh
/entrypoint &
if [ -f ${PUBLICIP_FILE} ] && [ -f ${PORT_FORWARDING_STATUS_FILE} ]; then
export ADDRESS=$(cat ${PUBLICIP_FILE}):$(cat ${PORT_FORWARDING_STATUS_FILE})
/app/entrypoint --server.address=0.0.0.0:$(cat ${PORT_FORWARDING_STATUS_FILE}) "$@"
elif [[ -z "`jobs`" ]]; then
echo "gluetun died" 1>&2
exit 1
else
sleep 10
fi