More often I’m working with 3rd party API’s and suchlike. One problem that developers often encounter is how to deal with this in dev when they cant open up ports on their local machine. One solution is to use a service like localtunnel this is great for quickly testing somthing but every time localtunnel looses connection you will get a different endpoint this means endlessly changing webhook links on API’s.

So how can we do this better? Well suprisingly easily if you have access to a public facing linux server.


# setup local

# setup remote

echo "Make sure $REMOTE_PORT is open on $REMOTE_HOST and 'GatewayPorts yes' is set in sshd.conf"

LOCAL=$(ifconfig $BIND_ADAPTER | grep 'inet ' | cut -d " " -f2 | awk '{print $1}')

As indicated by the script you have to open the port on your servers firewall and add the following to sshd.conf

GatewayPorts yes

BIND_ADAPTER might vary depending on your setup, use ipconfig to find the adapter your lan IP is bound to. Everything else should be fairly self explanatory.