ssh local tunneling – access home from remote location

Let’s say you have a raspberry running at home and you want to access it from your office.

If you have a google router you can easily set up IPv4 port forwarding 2222 -> 22

At this point from the office you can

ssh -p 2222 root@your-home-ip

and get inside your raspberry

Now, if from the office you want to browse your favourite web app running on port 80 on your server at home, then you use a local port forwarding

-L local-port:host:remote-port

sudo ssh -p 2222 -L 80:localhost:80 root@your-home-ip

If you now open your browser and write localhost, you will hit the webapp at home that runs on port 80