Saturday, December 10, 2011

Chrome Socks Proxy using SSH Tunnel

If you’re familiar with using a SOCKS proxy while browsing the internet you may have found out that Chrome will not work with a SOCKS5 proxy such as created when you create a SSH tunnel.

This is because chrome assumes the SOCKS proxy is a SOCKS4 proxy when it is SOCKS5.

A workaround is to have chrome read the proxy configuration from a script.
The configuration script is a javascript file with a function called FindProxyForUrl() that will be called for every HTTP URL to proxy.
Here is an example:


/**
* .pac files are for automated proxy configuration
* This is a fix for chrome to use SOCKS5 as it assumes SOCKS4
*/
function FindProxyForURL(url, host)
{
// no proxy for localhost
if (host.match('localhost') return false;
// proxy for other hosts
return "SOCKS5 localhost:8111";
}


Make sure your port number is the port that the socks proxy is bound to.

Save this script as ssh-tunnel.pac or similar and in chrome go to:
Options -> Under the Hood -> Network -> Change Proxy Settings

Chrome uses the same network settings as IE. So you will see the system window open and choose:
LAN settings -> Use Automatic Configuration Script

Enter the path to the ssh-tunnel.pac file you created.
Now reload the webpage in Chrome.

Creating an SSH tunnel.
If you’re not familiar with creating an SSH Socks5 proxy visit:
Windows SSH as Proxy
Linux SSH as Proxy


No comments: