SSH Connection – Accessing Remote Web Server

linuxopensshsshUbuntuwebserver

I recently set up a remote server, which I have running the bare minimums currently. I set up OpenSSH and can access the machine through one of my domain names (using an A-type DNS record). I also have a web server running on the machine, but all ports except SSH are blocked at the gateway.

While in the future I plan to open port 80, for now as I'm in "development" mode, and I would like to disallow any outside access or traffic to the web server through port 80 (or over the HTTP protocol for that matter). Right now, the only way to access the machine externally is through an SSH connection.

Now, I was wondering: how can I redirect the local HTTP server traffic through SSH so I can access my web server locally? Can this be done even if I have port 80 firewalled at the router/gateway?

Best Answer

yes, using ssh port forwarding.

ssh -L 80:localhost:80 name-of-remote-system

This will send any browser connection to port 80 on your local machine over ssh to the remote machine. Once there, it will continue to localhost (the machine you used ssh to connect to), port 80.

Related Question