Home | About | Apps | Github | Rss
There are several ways to open up your home webserver to the internet, the most popular one involves port forwarding. But it is not something that one can assume to be available in all situations.
If you do have a server already, we can use it to create a tunnel. This essentially involes 2 steps
This creates a tunnel between home_port and remote_port_x.
ssh -R <remote-port-x>:<home_localhost>:<home_port> <remote.server.com>
Example:
[8080] = remote port
[5000] = local port
ssh -R 8080:localhost:5000 [email protected]
By default, opening a reverse tunnel, will only bind it to the loopback interface. Which means, home computer will be accessible from localhost:<remote-port-x>
, but not from <remote.server.com>:<remote-port-x>
.
There are multiple ways to solve this
/etc/ssh/sshd_conf
on the remote serverGatewayPorts
to either yes
or clientspecified
ubuntu - sudo service ssh restart
Ensure that you add -g
option to step 1
, for step a
to work.
Since initial tunnel binds to loopback interface, this local-only tunnel, binds it to all interfaces on a different port, thereby exposing it to the internet.
ssh -L 0.0.0.0:<internet_port>:localhost:<remote-port-x> <remote.server.com>
<remote-port-x>
is the same port specified in step 1
Either of these tools can be used to relay traffic between the tunnelled port (I haven’t tried this yet)