Proxying Bittorrent

Michael Baudino michael.baudino at
Tue Sep 22 21:57:31 MSD 2009


I'm trying to proxy BitTorrent tracker traffic through nginx (0.6.32)
using the following configuration :
+--------+    +-----------+     (          )     +------------+
| BT Box |----| Nginx Box |----(  Internet  )----| BT tracker |
+--------+    +-----------+     (__________)     +------------+

My BitTorrent Box can access all other peers, but that's not the point here.

The point here is to proxy traffic from the BT Box to the tracker (which
is HTTP :

I'm using the /etc/hosts file on the BT Box to override name resolution and make it resolve to (the Nginx Box address).

BT Box only receives 502 Bad Gateway responses from the Nginx Box with
the following config :

server {

        access_log  /var/log/nginx/bt_access.log main;
        error_log   /var/log/nginx/bt_error.log debug;

        location / {
                proxy_set_header  X-Real-IP  $remote_addr;
                proxy_pass      http://$host$request_uri;

While it's receiving a good 200 response if I use one of the IP
addresses of the tracker instead of $host :


I could just go for it but the problems are :
- it does not use the tracker's DNS load-balancing system
- i cannot include other trackers in the server_name directive

So here is my question (finally !) :
- is it normal that proxy_pass'ing to $host returns a 502 Bad Gateway ?
- is there any other way to do what i want ?

Thanks in advance.

KameHouse Prod.

More information about the nginx mailing list