As some ISPs in the UK have been ordered to block it by the High Court, here are instructions on how to set up your own proxy server. The following piece also be explaining how it is a good and low cost investment with a great outcome – we must fight censorship, we cannot let this continue.
We’ll be using nginx on linux, preferably CentOS but it works on pretty much all UNIX-based systems. Your server should not have anything else running on port 80 though, and of course it needs sufficient bandwidth. Don’t use a precompiled binary from your distributions repos though as it will not have all the required modules. You can get good value VPS servers for next to nothing these days that will be more than capable of running it, ours costs less than £5 per month.
We are running piratereverse.info on a small linux VPS with 1GB of RAM and it currently uses around 50MB, going up to about 70MB when we get really busy. We’re also using SSL which is useful but not required. If you order a domain with namecheap.com you get WhoisGuard which is useful for this type of thing and a cheap SSL certificate. I think in total we paid less than £8 for the domain, whois protection and SSL certificate, all valid for one year.
1. Once you’ve got your server set up and online you’ll want to get nginx installed. Install the dependencies first.
yum install pcre-devel zlib-devel openssl-devel gcc make subversion
2. Download the source. Latest version is 1.2.0 as of 4/5/12.
3. Download the substitutions4nginx source using subversion.
svn checkout http://substitutions4nginx.googlecode.com/svn/trunk/ substitutions4nginx-read-only
4. Get ready to compile by configuring. Leave out –with-http_ssl_module if you aren’t planning on using SSL. Change the path of the substitutions4nginx-read-only directory to where you’ve downloaded it to.
./configure --with-http_ssl_module --add-module=/path/to/substitutions4nginx-read-only
5. Compile it. It’ll be installed to /usr/local/nginx/ by default.
6. Test nginx is working by starting it then typing in your server IP in your web browser. You should see the “Welcome to nginx!” message.
7. If its working, we’ll stop it so we can configure it. If you can’t connect to it, make sure there isn’t a firewall blocking it. For testing, run “service iptables stop” to stop iptables. You should configure iptables properly later but its not something in the scope of this article.
./sbin/nginx -s stop
8. Rename the default config file so we’ve got a copy just in case something isn’t quite right.
mv nginx.conf nginx.conf-backup
9. Download our config and open it.
10. You’ll need to modify some things for it to work for your setup.
A. If you aren’t using SSL, take out the first server block (the one with the rewrite rule) then take out all the SSL lines in the last server block, there are 5 in total, then change listen from 443 to 80.
B. Regardless of whether you are using SSL, change server_name to match your domain. You should not have any instances of ‘piratereverse.info’ in your config. The second server block is actually just serving this about section, I’ve added our IP in too so if you go to http://184.108.40.206/ for example you’ll see the about section too, so change to your own.
C. Then you can change the subs_filters on the final server block. You need to make sure that you change the domain on the first rule to your own, this will allow content to be proxied from static.thepiratebay.se over your server as some people had reported images and CSS not loading because their ISP had blocked that subdomain. That is really the only important subs_filter rule, the rest just insert our links into the source. Delete them if you don’t want them. You can also create new subs_filter rules to modify the content on demand, but don’t do anything silly like removing the banner ads.
D. Change the cache path if you want to, you could for example put the cache on a ramdisk to optimise it. Otherwise leave it as it is.
11. Make the cache directory. By caching we’ll be taking the stress off The Pirate Bay’s servers and speeding up delivery of our site. If you changed the cache path above then make sure its the same here too.
12. Test your config works by starting nginx. If there isn’t any output then its started. If you get [emerg] errors, something needs changing. Usually the output will point you in the right direction. If you can’t figure it out, try searching the internet as there are a lot of resources – otherwise email with as much detail as possible.
13. If it works, try it out. You’ve completed it. We recommend installing Webmin too, so you can see the error logs in the browser and manage the server with ease.
Spread the word
Please let people know about this – the more proxies that work properly the better.