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?

link|improve this question

feedback

4 Answers

up vote 2 down vote accepted

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 server port 80 then. To make that transparent you should add an entry to the hosts file. If you don't do that vhosts will not work.

link|improve this answer
If you need that tunnel to be available from clients outside your box, add the -g option. – mr-euro Oct 26 '09 at 15:35
feedback

Yes it is possible.

Run ssh -D port user@host and set up your client to use your box as a SOCKS proxy.

If you need a HTTP proxy specifically then you can use Proxychains and route it via the previous SOCKS.

link|improve this answer
feedback

Putty does this pretty well too.

Under SSH, goto Tunnels. At the bottom, put 8080 in the port, and for destination, leave it black and select the "Dynamic" radio button. Thats all you need to do, now connect to the server using Putty.

Once connected, you have a proxy server running on your localhost at port 8080 which will proxy all requests thru your server.

Now use a web browser and setup the proxy by setting host=localhost and port=8080 and make sure its a SOCKS proxy that you select. I do this all the time, so If you use Firefox, make sure to install the FoxyProxy plugin since it makes turning the proxy on/off a one click affair.

Caution: Be aware that by default, you'r DNS requests are not proxied. So the website that you visit via the proxy will still be logged (if they log this stuff). You can set firefox to proxy DNS requests as well, it just doesnt do it by default.

link|improve this answer
feedback

To allow a proxy to be run a computer, and allow other clients to connect to you will need the -g option. So for example, you would run this on the server named foo:

ssh -g -ND 9191 root@remotehost

You can then set the proxy in the browser of a client to use server foo and port 9191 for a SOCKS proxy. The clients will send their requests too foo, who in turn will forward the request through ssh to remotehost. So on the internet, it will look like they are using remotehost.

If you want to forward DNS requests as well with firefox, edit the about:config in firefox and set network.proxy.socks_remote_dns to true.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.