SSH – How to Create SSH Tunnel for HTTP Proxy

httpPROXYsshssh-tunnel

Say I have a server and client. I need to create connection from client to a website through server like it was proxy.

Is it possible to do this using a SSH tunel, or do I have to install some proxy service to the server?

Best Answer

You can do this using ssh

ssh -L 80:remotehost:80 user@myserver

You will have a tunnel from your local port 80 to the remotehost port 80 then. This does not have to be the same as myserver. To make that transparent you should add an entry to the hosts file. If you don't do that vhosts will not work. If you want a SOCKS-proxy connection you could also use

ssh -D 5000 user@myserver

This will create a SOCKS-proxy on localhost port 5000 which routes all requests through myserver.