Proxying Bittorrent

Igor Sysoev is at rambler-co.ru
Wed Sep 23 00:38:39 MSD 2009


On Tue, Sep 22, 2009 at 07:57:31PM +0200, Michael Baudino wrote:

> Hello,
> 
> 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 :
> http://wiki.theory.org/BitTorrentSpecification#Tracker_HTTP.2FHTTPS_Protocol).
> 
> I'm using the /etc/hosts file on the BT Box to override
> tracker.openbittorrent.com name resolution and make it resolve to
> 10.73.0.14 (the Nginx Box address).
> 
> BT Box only receives 502 Bad Gateway responses from the Nginx Box with
> the following config :
> 
> server {
>         listen 10.73.0.14:80;
>         server_name  tracker.openbittorrent.com;
> 
>         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 :
> 
>                 proxy_pass      http://188.126.64.3$request_uri;
> 
> 
> 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 ?

If you look in error_log for 502 reason, you will
"... no resolver defined to resolve tracker.openbittorrent.com ..."
You need to set up localhost named or use any existant one:

http {
     resolver  127.0.0.1;


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list