As you may already know, the British government recently decided to censor The Pirate Bay, and a group of other, similar sites. Personally, I’m completely against censorship, and so I decided to setup my own Pirate Bay proxy (tpbproxy.info), with help from the instructions over at http://proxybay.info/setup.html.
Nginx vs PHP
First of all, if you are setting up your own proxy, I would recommend you do it properly. Too many proxies out their are broken, slow, or just plain crap, and so I would highly recommend using nginx.
The benefit to using nginx, as opposed to, PHP, is that nginx is much, much faster than PHP+Curl, and uses a lot less memory. Nginx is more complicated to setup, however, so if that is an issue then you may want to go with PHP. If you are going with PHP you will need a lot more RAM. With nginx you will be able to get away with 64-128MB.
I recommend using a VPS provider that offers precise control over the RAM, such as TailoredVPS.com, although you will need to enquire about their open proxy policy.
Setting up the nginx proxy (Debian)
This guide is for setting up a fast proxy under Debian/Nginx. It is a slightly improved version of the one originally found at http://proxybay.info/setup.html, and I would recommend the original if you are using CentOS, as I have not built any RPMs for that, although I would still recommend using the latest version of nginx and my adapted config instead, as both of these solve some original bugs from the original guide.
1.) Install Nginx (with substitutions4nginx module)
To do this you will need to add debian backports, apt-get build-dep nginx, apt-get source nginx, then git clone substitutions4nginx into debian/modules directory, modify debian/rules file, then add substitutions4nginx module into the rules file and build the package.
2.) Download my adapted sample config, modify it for your needs, and place it into /etc/nginx/sites-enabled
wget http://rickyhewitt.com/downloads/tpbproxy/tpbproxy.info.conf
3.) Create the cache directory
mkdir /usr/local/nginx/cache
4.) All done, start nginx!
/etc/init.d/nginx start
Finally..
You should now have an nginx proxy server running in a mere few MB of ram at most, while remaining much faster and more reliable than PHP+Curl or most (if not all!) other solutions. You can use the subs_filter directive within your nginx config file to automatically replace content.
If you are looking to provide a small advertising revenue to the server, then I would recommend against overloading it with Ad’s, as it will impede performance for users — however, you could use the sub_filter directive, combined with an agency that would accept such traffic, such as popcash.net.
If you have any questions, or issues with creating your own server, then feel free to let me know, and I may be able to help.


