I was doing a little bit of testing on a web app earlier today and I wanted to be able to switch my IP easily. I’d never used a web proxy before, I’ve never had the need to.
First I found some free proxy listings on sites like HIDE MY ASS, these give you an IP address and port to connect to from your browser. This did the trick but I felt a little vulnerable going through some random proxy. This wasn’t the solution for me.
Then I found Squid. This solved all my problems in one beautiful move, all I needed was a box somewhere to do my dirty work (luckily I have a very reasonable droplet at Digital Ocean) and the following setup.
1. Install the Squid server on Ubuntu 12.04
2. Make a backup of the config file before you mess it up :)
For the next few steps I’m going to use some pretend IPs for the purpose of this post. Let’s say my home IP address (where I’m using my browser) is “188.8.131.52” and my server’s IP address is “184.108.40.206”.
3. Add some Squid config lines to allow access from your home machine
The first line needs to come first :) and is best kept with the other default
acl config lines. The second line needs to come before the default deny from all
http_access deny all.
4. Restart Squid
You can now test your proxy. Open your browser and set your proxy configuration. There are lots of tutorials around for this sort of thing, if using Chrome you can follow a handy tutorial; set the IP to “220.127.116.11” (your proxy server) and the port to “3128” (default port for Squid) unless you change the port in the squid config. If you visit a site like http://www.whatismyip.com/ you should see the IP as “18.104.22.168”. You may also notice that it has recognised you using a proxy and says that this is via “22.214.171.124”.
Top Tip: do you use a firewall? Make sure port 3128 is open for incoming traffic.
5. Make it Anonymous, add the following to the bottom of your config
The first two lines tell squid that any connection coming in on “126.96.36.199” should have an outgoing IP of “188.8.131.52”. You can set your outgoing to whatever you like.
6. Restart Squid (see point 4)
And we’re done. You’re proxy server is now set up safely and anonymously. You can add incoming IPs so that you can access it from other locations and configure it to your hearts content.
To make life even easier, using Chrome I added the Proxy Switchy! extension. This allows me to save as many proxy profiles as I like to easily switch between.