Issue
I have a RaspberryPi in my private local network (example: 192.168.1.2) and I have a dedicated server (example: 99.99.99.99) from some provider. From my RaspberryPi I can connect to the server via ssh without trouble, the opposite situation is not possible. The RaspberryPi is not reachable from the internet. Now I want to reach the webserver on my RaspberryPi from the internet with some ssh brigde/tunnel. So if I enter the IP 99.99.99.99 in my browser, I want to see the website from the RaspberryPi. How it is possible?
Solution
The -R
option to ssh will permit a remote tunnel to be opened towards the ssh client. So, if from the pi you run
ssh -R0.0.0.0:8080:address_of_pi:80 99.99.99.99
Then you will open an ssh and while that ssh is active anyone can go to 99.99.99:8080
and get to your pi.
You need to use 8080 as the port on the webserver address because the ssh process cannot bind to port 80 without being root.
Answered By - Sam Hartman Answer Checked By - Katrina (WPSolving Volunteer)