This guide will explain how to set up your own Pirate Bay proxy site. A proxy site will help users in countries where The Pirate Bay has been blocked. Many ISP's in countries such as the United Kingdom and The Netherlands have been forced to block The Pirate Bay.

For most of the article we'll be using a web server called Nginx. It has been tested on Red Hat based and Debian based distributions 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.

There is also a PHP script that proxies The Pirate Bay that has been designed specifically for this, and can be used on web hosting packages (i.e. does not require a server dedicated to it). If you are planning on doing this, make sure you aren't violating any terms of service that your provider has.

Special thanks to @PirateReverse for the instructions

This PHP script is a proxy designed specifically for providing access to The Pirate Bay. A great solution if you do not have a server that you can dedicate to the task. It was created by ikwilthepiratebay.nl and requires at least PHP5 and cURL.

To install, just unzip it and upload the files to your web server. Rename htaccess.txt to .htaccess (The dot in front is important)

If the script doesn't work, make sure the .htaccess file exists in the same directory as proxy.php. You can also try removing the RewriteBase line from the htaccess file as well to see if that helps.

Download - Last updated Jan 5, 2013

The script can also be downloaded from Github here

There is also an alternative PHP proxy script that can be downloaded here

If you have a Wordpress website, you can install this plugin to allow your site to uncensor The Pirate Bay and other websites.

Any WordPress powered website with this plug-in will immediately start functioning as a proxy for the censored websites.

Repress plugin for Wordpress

We have preconfigured nginx for Windows into a Pirate Bay proxy. Just download it, run start.bat and configure your router and you have a fully functional proxy that you can share.

Download v1.0 based on nginx/1.2.0

This will only work if your ISP has not blocked The Pirate Bay, if they have then your proxy will be serving their block page rather than the actual Pirate Bay site. If your ISP has blocked it and you need to access The Pirate Bay, check out this list of proxies.

Once the software is running you will need to forward port 80 on your router or firewall to the IP of the computer with nginx. This guide about Apache will help as it uses the same port. You will also need to open nginx.conf in the conf directory and change where it says 127.0.0.1 to your external IP address or hostname. If you don't have a static IP address, use a service like no-ip.com to get a free hostname and dynamic DNS.

1. Once you've got your server set up and online you'll want to get nginx installed.

a) Install the dependencies first, this is for a Red Hat based system.

yum install pcre-devel zlib-devel openssl-devel gcc make subversion

b) If you're using a Debian based operating system you should use this.

apt-get install libpcre3 libpcre3-dev zlib1g zlib1g-dev openssl gcc make subversion

2. Download the source. Latest version is 1.4.2 as of 26/09/2013.

wget http://nginx.org/download/nginx-1.4.2.tar.gz

3. Download the substitutions4nginx source using subversion.

svn checkout http://substitutions4nginx.googlecode.com/svn/trunk/ substitutions4nginx-read-only

4. Extract the source.

tar xzvf nginx-1.4.2.tar.gz
cd nginx-1.4.2

5. Get ready to compile by configuring. Change the path of the substitutions4nginx-read-only directory to where you've downloaded it to. If you haven't changed the path and are logged in as root it'll probably be /root/substitutions4nginx-read-only/

./configure --add-module=/path/to/substitutions4nginx-read-only

6. Compile it. It'll be installed to /usr/local/nginx/ by default.

make
make install

7. 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.

cd /usr/local/nginx/
./sbin/nginx

8. 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, see this shell script. You should configure iptables properly later but its not something in the scope of this article, instead see here.

./sbin/nginx -s stop

9. Rename the default config file so we've got a copy just in case something isn't quite right.

cd conf
mv nginx.conf nginx.conf-backup

10. Download this config file and open it. Have a look at it here online first if you're unsure.

wget http://proxybay.info/assets/proxy/nginx.conf
vi nginx.conf

11. 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.

./usr/local/nginx/sbin/nginx

14. If it works then submit it to The Proxy Bay by going to This Link.

One of the advantages with nginx is that it works on a Mac too. This guide will explain how to configure it. You'll need to have Xcode installed, but that is free from Apple.

1. Configure the dependencies by going to the Terminal (Applications > Utilities) and paste in the following. If it does not work, paste it in each line at a time (note that the long URL on the first line wraps over onto the second, but it should be treated as a single line).

sudo curl -OL h ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz > /usr/local/src/pcre-8.30.tar.gz 
sudo mkdir -p /usr/local/src
cd /usr/local/src
tar xvzf pcre-8.30.tar.gz
cd pcre-8.30
./configure --prefix=/usr/local
make
sudo make install
cd

2. Download nginx source and untar it.

sudo curl -OL h http://nginx.org/download/nginx-1.4.2.tar.gz > /usr/local/src/nginx-1.4.2.tar.gz
tar xvzf /usr/local/src/nginx-1.4.2.tar.gz

3. Download the substitutions4nginx source using subversion.

cd /usr/local/src/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.

cd nginx-1.4.2./configure --with-http_ssl_module --add-module=/path/to/substitutions4nginx-read-only

5. Compile it. It'll be installed to /usr/local/sbin/ by default.

make
sudo make install

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.

sudo /usr/local/sbin/nginx

7. If its working, we'll stop it so we can configure it. If there are any problems, try installing it again using this guide but make sure you include the "--add-module=/path/to/substitutions4nginx-read-only" parameter to ./compile

sudo /usr/local/sbin/nginx -s stop

8. Rename the default config file so we've got a copy just in case something isn't quite right.

cd /usr/local/conf/
mv nginx.conf nginx.conf-backup

9. Download this non-SSL config and open it. Have a look at it here online first if you're unsure.

wget http://proxybay.info/assets/proxy/nginx.conf
vi nginx.conf

If you are using SSL, download this config and open it. Have a look at it here online first if you're unsure. This is for SSL.

wget http://proxybay.info/assets/proxy/nginx-ssl.conf
mv nginx-ssl.conf nginx.conf
vi nginx.conf

10. If you aren't using SSL the only thing you should consider changing is the subs_filters, or you can remove them. They perform a find and replace. If you are using SSL change the paths of the SSL certificates as appropriate and edit the server_name so it is relevant.

11. Test your config works by starting nginx. 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.

sudo /usr/local/sbin/nginx

12. If it works then submit it to The Proxy Bay by going to This Link.

If you have a Linux VPS or dedicated server and are running the Apache web server, you can set up a reverse proxy

Steps for Debian based systems (E.g. Ubuntu)

1. Install two Apache modules, mod_proxy and mod_proxy_http. Enter the following two commands in your shell

a2enmod proxy
a2enmod proxy_http
a2enmod headers

2. After the two modules have been enabled, you can create a new Virtual Host. This may differ on you system but on my system, I created a new file:

sudo nano /etc/apache2/sites-available/yourdomain.com

3. Add the following configuration to the file (Replace 'yourdomain.com' with the domain you wish to use):

<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName yourdomain.com
  <Proxy *>
    Order deny,allow
    Allow from all
  </Proxy>
  ProxyRequests off
  ProxyPassReverseCookieDomain .thepiratebay.se .yourdomain.com
  ProxyPreserveHost on
  ProxyPass / http://194.71.107.80/
  ProxyPassReverse / http://194.71.107.80/
  RequestHeader unset Accept-Encoding
</VirtualHost>

4. Enable the site

sudo a2ensite yourdomain.com

5. Restart Apache

/etc/init.d/apache2 restart

The site should now be functioning at your domain.

Steps for Red-Hat based systems (e.g. Centos)

1. You will need to enable two Apache modules, mod_proxy and mod_proxy_html. See this link on how to enable modules.

2. After the two modules have been enabled, you can create a new Virtual Host. This is usually done by going to the /etc/httpd/conf.d/ directory and creating a new file

nano /etc/httpd/conf.d/yourdomain.conf

3. Add the following configuration to the file (Replace 'yourdomain.com' with the domain you wish to use):

<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName yourdomain.com
  <Proxy *>
    Order deny,allow
    Allow from all
  </Proxy>
  ProxyRequests off
  ProxyPassReverseCookieDomain .thepiratebay.se .yourdomain.com
  ProxyPreserveHost on
  ProxyPass / http://194.71.107.80/
  ProxyPassReverse / http://194.71.107.80/
  RequestHeader unset Accept-Encoding
</VirtualHost>

4. Restart Apache

service httpd restart

The site should now be functioning at your domain.

Once you have set up your proxy and can confirm it is working, submit it to The Proxy Bay

Submit your proxy