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.

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

a) If you're using a Debian based OS (e.g. Ubuntu), run this:

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

b) If you're using a Red Hat based OS (e.g. Centos), run this:

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

2. Download the source. You can find the latest version here.

wget http://nginx.org/download/nginx-1.6.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.6.2.tar.gz
cd nginx-1.6.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 --with-http_ssl_module --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 it's working, we'll stop it so we can configure it.

./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. Copy the following config and insert it into nginx.conf

#Change to number of CPU's on server
worker_processes 1;
events {
  worker_connections 1024;
}
http {
  include  mime.types;
  default_type application/octet-stream;
  sendfile on;
  gzip on;
  server {
    listen 80;

    #Change to your domain name
    server_name yourdomain.com;
    location / {
      proxy_pass https://thepiratebay.se/;
      proxy_set_header Accept-Encoding "";
      proxy_set_header Host thepiratebay.se;
      proxy_set_header CF-Connecting-IP ""; #Required if using Cloudflare
      
      #Substitution examples http://wiki.nginx.org/HttpSubsModule
      subs_filter '<strong id="howdl">.*<\/strong>' '<strong id="howdl"><a href="https://proxybay.co">List of Pirate Bay proxies</a></strong><br>' r;
      subs_filter 'thepiratebay.se' $host;
    }
  }
}

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

./usr/local/nginx/sbin/nginx

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

15. You can set up an init script to start/stop/reload/restart nginx more easily. See how here. It's also a good idea to make nginx start at boot. For Redhat based distros and for Debian based distros.

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 three Apache modules, mod_proxy, mod_proxy_http and deflate. Enter the following command in your shell

a2enmod proxy ssl proxy_http headers deflate 

2. After the two modules have been enabled, you can create a new Virtual Host. This may differ on your 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>
  SSLProxyEngine On
  ProxyRequests off
  ProxyPassReverseCookieDomain .thepiratebay.se .yourdomain.com
  ProxyPreserveHost off
  ProxyPass / https://thepiratebay.se/
  ProxyPassReverse / https://thepiratebay.se/
  RequestHeader unset Accept-Encoding
<Location />
  SetInputFilter DEFLATE
  SetOutputFilter INFLATE
  AddOutputFilterByType SUBSTITUTE text/html text/css application/x-javascript application/javascript
</Location>
</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 three Apache modules, mod_ssl, mod_proxy, mod_proxy_html, and deflate. 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 / https://thepiratebay.se/
  ProxyPassReverse / https://thepiratebay.se/
  RequestHeader unset Accept-Encoding
<Location />
  SetInputFilter DEFLATE
  SetOutputFilter INFLATE
  AddOutputFilterByType SUBSTITUTE text/html text/css application/x-javascript application/javascript
</Location>
</VirtualHost>

4. Restart Apache

service httpd restart

The site should now be functioning at your domain.

These two PHP scripts are 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. They require PHP5 and cURL.


PHP-The-Pirate-Bay-Proxy

This script uses .htaccess to load the proxy script and modify the URL's. Therefore, your server will need to run Apache for the .htaccess file to work

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. Otherwise, try the alternative script below

To install, just unzip it and upload the files to your web server.

Download here


Unblocked Pirate Bay PHP Script

This is another script that proxies The Pirate Bay. This script does not use .htaccess and is likely to be more compatible with web servers

Simply upload it to your web host and modify includes/config.php. You can also customize the home page by editing home.html

Download here

Setting up an OpenBay site is useful if the Pirate Bay is down, otherwise, it is recommended to set up a proxy

OpenBay allows you to set up a Pirate Bay clone site. This will essentially create a clone of the pirate bay site and database on your own server. This is different from a proxy site which connects to a backend site (such as the pirate bay).

You will need PHP for the basic setup

For instructions and the code, click here: OpenBay

Find a good Web Host

Try looking for a provider that ignores DMCA requests and is not based in the USA or UK. Some hosts (even in Europe) will honour DMCA takedowns, so it's good to do your research. Try doing a Google search for keywords such as: offshore, vps, dmca.

Here are two hosts that I recommend: Bahnhof and Sweden Dedicated


Use a CDN

Use a free CDN service such as Cloudflare to help speed up your site and lessen the load on your server. It will also conceal the true location of your server. Another free CDN provider is Incapsula

Note: If you are using Cloudflare, you will need to add proxy_set_header CF-Connecting-IP ''; to your Nginx config for it to work. Otherwise, you will get DNS errors


Use SSL

Aside from protecting the privacy of your users, using SSL can also bypass a lot of blocks from ISP's. Therefore, it is highly recommended to use SSL for your proxy

Cloudlfare automatically provides an SSL certificate for your site so you can simply add https in front of your domain.

If you buy your own certificate, be sure to follow the SSL best practices, such as enabling HSTS and using modern ciphers. Here is a guide for NGINX


Use NGINX

NGINX is the fastest and most reliable proxy method available. Otherwise, the Apache method is also a good option. The PHP scripts should be used if you are unable to setup the other options

Take a look at the NGINX Documentation to further configure it to your needs

Here is a guide on how to optimize NGINX


Find a good Domain Registrar

I recommend Hover, EasyDNS, or NameCheap.

Avoid GoDaddy, Register.com, Network Solutions and Web.com


Use WHOIS privacy on your domain name

When you register a domain name, your billing/registration information usually becomes public in the public WHOIS database. Therefore, anyone can go on a Whois search site and lookup your domain.

Some domain names do not support WHOIS privacy and will require your contact details to be public. In that case, you can try inputting fake data. However, be aware that this might be against the terms of your domain registration. Here is More information.


Get a Free Domain Name

Using FreeDNS, you can register a free subdomain name (e.g. subdomain.domain.com). This is free and doesn't require you to register or pay for a regular domain. However, since it's a subdomain, you don't control the name servers and cannot use it with services like Cloudflare

Another option is to get a free domain from Freenom. Since these are regular domains (e.g. domain.tk), you can set up name servers to point at services such as Cloudflare


Monitor your site

Here are some free options to monitor the uptime of your site: Montastic, Monitor.us, Uptime Robot

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

Submit your proxy