Skip to content

Instantly share code, notes, and snippets.

@perusio
Forked from jpluscplusm/gist:4366287
Last active July 29, 2017 02:08
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save perusio/4404063 to your computer and use it in GitHub Desktop.
Save perusio/4404063 to your computer and use it in GitHub Desktop.
A pirate bay proxy configuration for Nginx
server {
listen 80; # IPv4
listen [::]:80 ipv6only=on; # IPv6
server_name ~^(?<thishost>[^.]+\.)?subdomain\.example\.com$;
access_log off;
location / {
## Resolve the upstream address using this DNS server or any other.
## Choose the one that suits you.
resolver 8.8.8.8;
## Apply the substitution filter as many times as necessary.
sub_filter_once off;
## All references to 'piratebay.se' are to be replaced by our proxy.
sub_filter 'thepiratebay.se' 'subdomain.example.com';
## Proxy pass all requests to our upstream.
proxy_pass https://${thishost}thepiratebay.se;
## We have to disable gzip and other non-identity encodings. Only identity is acceptable.
proxy_set_header Accept-Encoding ''; # otherwise content sub fails
## No gzipping at all.
gzip off;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment