Use your Amazon EC2 as HTTP proxy

From China, opening a stackoverflow page takes around 2 mins and loading Google chart API 3 mins, all thanks to the infamous Great Firewall (GFW). This is a pain for any developer. If you have a server elsewhere, you can use your own server as a proxy, as follows.

 

1. Download and install Bitvise SSH client (www.bitvise.com). Under Services tab, tick "SOCKS/HTTP Proxy Forwarding Enabled", with Listen Interface 127.0.0.1. Rest leave as it is. Under Login tab, input your server host and authentication methods. For ssh keys authentication, use the built-in keypair manager.

 

2. Click login. You should see:

10:33:19.064 Attempting 'publickey' authentication. Using keypair at slot 1.
10:33:19.400 Authentication completed.

Now we configure the system/browser to use our proxy. This could be done within IE or within some plugins for your working browser, like AutoProxy for Firefox or SwitchySharp for Chrome. Either way, you will set the proxy for SOCKS Host as 127.0.0.1, port 1080. The rest leave blank.

 

3. Lastly, for those who uses Amazon EC2 server, you might see this error:

09:11:10.305 SOCKS4 connection from 127.0.0.1:4344 failed: Client connection closed before completion of protocol.

It's because some plugins use remote DNS resolving. But Amazon's DNS server seems to fail to resolve the request. The solution is to edit your server /etc/resolv.conf. Change the nameserver item to 8.8.8.8 (Google's DNS server). It should work fine now.

Written on December 12, 2013