DEV Community

loading...
Cover image for [Video] How to proxy your web traffic via your Linux Server without a VPN

[Video] How to proxy your web traffic via your Linux Server without a VPN

bobbyiliev profile image Bobby Iliev Originally published at devdojo.com ・2 min read

In this video, I will show you a pretty cool and easy way on how to proxy your web traffic without having to install a VPN or do any special server configuration by just using SSH tunneling!

All you would need is a server and SSH access.

You can use my DigitalOcean referral code to get a free $100 credit to spin up your own servers:

Free $100 DigitalOcean credit

The command that you would need to use is:

ssh -ND 1080 root@your-server.com
Enter fullscreen mode Exit fullscreen mode

There would be no output. This would open a socket that we would use to connect to and proxy our network traffic.

Rundown of the command:

  • -N - Do not execute a remote command. This is useful for just forwarding ports also hides the output from the SSH connection.

  • -D - 1080 creates a local “dynamic” application-level port forwarding, in this case 1080, on your local computer. Whenever a connection is made to this port, the connection is forwarded over the secure channel, and the application protocol is then used to determine where to connect to from the remote machine. Currently the SOCKS4 and SOCKS5 protocols are supported, and ssh will act as a SOCKS server.

Once you have the socket ready you can use any browser to connect to the SSH tunnel. In my case, I would use Firefox.

You need to go to Preferences -> Advanced -> Network -> Settings -> And update your Configure Manual proxy configuration.

Update the SOCKS HOST to localhost and the port to 1080. Make sure to choose SOCKS v5.

This is pretty much it, now all of your Web Traffic would be routed through your Web Server:

To stop the SSH tunnel, just interrupt the SSH connection and change your Firefox settings back to No Proxy.

Discussion (3)

pic
Editor guide
Collapse
realtebo profile image
Mirko Tebaldi

Could you suggest a use case?

Collapse
koas profile image
Koas

There are some services that are restricted to users from a certain country. Here in Spain, for example, you can watch the state TV channels from their website but only if you connect from Spain.

Using the method Bobby explained you can use a spanish server as a proxy and watch those channels from anywhere in the world, since to the TV site you'll look as if you're connecting from inside Spain.

Collapse
bobbyiliev profile image
Bobby Iliev Author • Edited

Yep, thank you for the answer @koas ! 🙌

Whenever you need to browse the web from another IP you can use this approach rather than setting up a full-blown OpenVPN server or paying for a VPN service.