deluge-web behind an nginx reverse proxy

My nginx configuration to reverse proxy deluge-web needed a few subtle tweaks before it worked correctly, see below.

~/.config/deluge/web.conf

{
  "file": 1,  
  "format": 1
}{
  "port": 8112, 
  "https": false, 
  "base": "/", 
  ... 
}

/etc/nginx/sites-enabled/deluge.conf

...
  location /deluge/ {
    allow                         127.0.0.1;
    allow                         192.168.1.0/24;
    deny                          all;
    proxy_pass                    http://127.0.0.1:8112/;
    proxy_redirect                off;
    proxy_set_header              Host            $host;
    proxy_set_header              X-Real-IP       $remote_addr;
    proxy_set_header              X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header              X-Deluge-Base   "/deluge/";
    proxy_pass_header             Set-Cookie;
    proxy_pass_header             P3P;
  }
...

The trailing slashes are very important for location, proxy_pass and X-Deluge-Base. Also notice that I left base in ~/.config/deluge/web.conf blank.

With this configuration you will be able to access the Deluge web interface via http://www.example.com/deluge (no trailing slash required). Keep in mind that it will also be accessible directly on port 8112, because you can't make it listen on locahost only yet. Unless you patch it in yourself. So don't forget to add a firewall rule.

Sources

Tagged , ,