Pontus Öwre

Dedicated and diverse software engineer with 15+ years professional experience. Passionate about software security, test driven development and DevOps with interest in getting things done.

Tunneling http traffic through ssh

Posted

When you need to access a web server that is behind a firewall or on a private network, you can use an ssh tunnel to securely forward http traffic. This is useful when you want to access a web server that is not directly accessible from the internet or when you want to encrypt your http traffic.

Issue the following command to establish an ssh tunnel that forwards http traffic from your local machine to the remote server:

ssh -NL 8080:127.0.0.1:80 remote_user@182.105.111.213 This command creates a tunnel from port 8080 on your local machine to port 8080 on the remote machine. -N indicates that we don’t want to execute any remove command since we only want a port to be forwarded. -L specifies that the given port on the local (client) host is to be forwarded to the given host and port on the remote side. In this case, we are forwarding port 8080 on the local machine to port 8080 on the remote machine.

Refer to the ssh manual for further details on the ssh command.