Reverse port forwarding
Accessing your local development server from the outside world.
It’s often the case that you have a local development server that you wish you could access over the interwebs. Perhaps you need to do a demo, show a prototype to a colleague, or integrate with external servers that can’t connect directly to your laptop.
In the past I’ve gone through a laborious hack→build→push→run→test cycle that is slow and inefficient.
Enter reverse port forwarding, the age old technique of SSH Tunneling.
All you need is access to a remote server that can be accessed from the outside world, such as an EC2 instance or a VPS.
First off, log in to your remote server and open /etc/ssh/sshd_config. If it does not already exist add the line:
GatewayPorts clientspecified
Then restart the SSH daemon:
sudo /etc/init.d/ssh restart
# or
sudo service sshd restart
Back on your laptop, start your development server and then in another terminal run the following:
ssh -N -R :3000:localhost:4000 user@12.34.56.78
This will forward requests to port 3000 on your remote server to port 4000 on your laptop. Visiting http://12.34.56.78:3000 will be handled by your laptop.
(Substitute ports and IP addresses as appropriate.)
That’s it.
This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at fivefilters.org/content-only/faq.php#publishers.