[How To] Always on, remotely accessible torrent server


Like many people I leave my OSMC box running all the time (both of them) as they use very little electricity and the lack of a power button on the Pi makes turning them back on rather awkward as the plug is burried behind the TV. That said there is a long part of the day when it is sat idle and I wanted to make use of that time, so what better to do that have it manage all the household torrents so PCs don’t have to be left on for lengthy periods of time (saving money and the environment!). Also I wanted a way to add torrents and check torrent progress when we weren’t at home. Ideally I wanted a setup that provides a single solution for the whole household to download torrents from phones and tablets via apps, from remote computers via a secure web page and internally using torrent software on their own Linux/Windows machines - the holy grail of a platform independent solution. With the below that is exactly what I’ve created and following this guide you can too.

I run this on my Raspberry Pi 2 but have previously run it successfully on a Raspberry Pi 1 too. I don’t have a Vero or ATV to test it on, but I don’t see any reason why it shouldn’t work there also.

#Legal note#

Torrents have a bad press (and have had for some time) as a major source of pirated content and whilst that is true there are also many legitimate reasons why someone may want a torrent server - lots of FOSS software is distributed by torrent for example to lighten the bandwidth on the origin servers. Neither this setup, nor any other, will take any steps to check the legitimacy of any file you may download - that is your responsibility before you start each torrent. Please be careful what you download, your IP may be logged and depending on your jurisdiction there may be penalties if you download something made available illegally.

That said, lets get down to setting it up.

#The Torrent Server#

This guide uses Deluge. Yes I know there are others available that may have more features, but I have found Deluge to be more than capable, reasonably lightweight and it is available cross-platform with no major differences.

All of this guide is done through the terminal over SSH. If you don’t know how to connect via SSH, there is an excellent article in the OSMC wiki.

Firstly ensure your system is fully up-to-date:

sudo apt-get update && sudo apt-get dist-upgrade

Then install the required software:

sudo apt-get install deluged deluge-web nginx - you’ll need to press Y to accept any other dependent packages.

We want deluge to save files that the osmc user can at least read so we’ll add osmc to the new debian-deluged group and run it with that group so that the files it saves will be accessible to osmc. The directory/ies it writes to (see later) need to have read/write permissions for the debian-deluged user.

sudo adduser osmc debian-deluged (if you have other users defined on your system run that command for them to so they can access the torrent files).

Deluged (the background daemon) ships as disabled so we need to enable it before proceeding: sudo nano /etc/default/deluged and change ENABLE_DELUGED=0 to ENABLE_DELUGED=1

OSMC uses systemd instead of the older init.d method of starting services, so lets use that to deal with starting things automatically at boot time, it will make managing things easier later on.

Firstly, delete the old way to prevent future confusion:

sudo update-rc.d deluged remove
sudo rm /etc/init.d/deluged

Then create a systemd unit as follows:

sudo nano /etc/systemd/system/deluged.service

and add the following text:

Description=Deluge Bittorent Daemon


ExecStart=/usr/bin/deluged -d


# Configures the time to wait before service is stopped forcefully.


Finally for this step systemd needs to be made aware of the new files and then reloaded to pick up the new unit.

sudo systemctl daemon-reload
sudo systemctl enable deluged.service

The daemon can now be started with sudo systemctl start deluged and will run automatically when the machine boots up, although we need to configure a few things before it will work correctly:

Firstly decide where to store your torrents. For ultimate flexibility you’ll need three directories:

  1. A directory into which you can drop .torrent files to be picked up automatically.
  2. A directory that holds files as they are being downloaded.
  3. A directory that holds completed torrents.

I have a hard drive permanently mounted at /mnt/data and I created /mnt/data/TorrentFiles/, /mnt/data/Torrents and /mnt/data/CompletedTorrents respectively, but create what ever structure you would like and make a note of it. Once you’ve created your directories chown them to the debian-deluged user (sudo chown debian-deluged:debian-deluged /path/to/each/directory) so that deluge can write to them.

If you haven’t started the daemon yet start it with the command above and then stop it with sudo systemctl stop deluged, this will create the default configuration we need to get started. Then: sudo nano /var/lib/deluged/.config/deluge/core.conf (be careful with the path here - the deluge installer creates /var/lib/deluged/config/ but the daemon doesn’t use this it creates and uses /var/lib/deluged/.config/deluge/) and change the following settings to your preferences (the others are best left alone!):


"move_completed_path": "/var/lib/deluged/Downloads",
"torrentfiles_location": "/var/lib/deluged/Downloads",
"max_active_limit": 8,
"max_active_downloading": 3,
"max_active_seeding": 5,
"allow_remote": false,
"download_location": "/var/lib/deluged/Downloads",
"max_connections_global": 200,
"max_connections_per_torrent": -1,
"move_completed": false,
"autoadd_enable": false,
"max_upload_slots_per_torrent": -1,
"autoadd_location": "/var/lib/deluged/Downloads",
"max_upload_slots_global": 4,


"move_completed_path": "/mnt/data/CompletedTorrents",
"torrentfiles_location": "/mnt/data/Torrents",
"max_active_limit": 10,
"max_active_downloading": 5,
"max_active_seeding": 5,
"allow_remote": true,
"download_location": "/mnt/data/Torrents",
"max_connections_global": 200,
"max_connections_per_torrent": 50,
"move_completed": true,
"autoadd_enable": true,
"max_upload_slots_per_torrent": 10,
"autoadd_location": "/mnt/data/TorrentFiles",
"max_upload_slots_global": 10,

I’ve listed these entries in the order they appear in the default file, so it shouldn’t take you long to find them amidst the others.

Setting “-1” on the numeric options will set them to unlimited.

“move_completed” and “move_completed_path” can be quite useful as it will move files to another directory only when they have finished downloading - you can then guarantee that any files moved/copied from that location are fully downloaded (I share this folder via samba so users only see downloaded files after they’re ready).

“autoadd_enable” and “autoadd_location” when enabled and a location is set mean that you can start a torrent just by putting the .torrent file in this folder. (Again I share this folder via samba so I just save the .torrent file to this location and deluge does the rest, they then appear in the other folder when complete).

“allow_remote” is required if you are going to configure other clients to use the server as per the next section of this guide or if you want the web interface, so set it to true here.

The torrent server (daemon) is now configured, start it back up with sudo systemctl start deluged and check it is running ok with sudo systemctl status deluged

This doesn’t yet do anything however as we currently have no way of connecting to it. There are two options here:

  1. Use just the web interface and/or mobile apps to connect in which case you can skip the next part and go to “Web Interface and Apps” below.

  2. Use this as a remote downloader from your PC (or any number of computers in your house) in which case read on from here.

#Configuring remote client access#

This will allow you to install the deluge software on your PC (Linux or Windows) and have it start torrents on your OSMC box instead of on the machine it is installed on.

Before you can connect remotely you need to add a user (you can add as many here as you’d like but at the moment deluge makes no distinction between users so there’s little point adding more than one). To add users run sudo nano /var/lib/deluged/.config/deluge/auth [you may need to change this path if your installation has used the config directory instead of the .config one as above] and add a line at the end of the file with the username and password you require as follows (the :10 at the end is both vital for this to work and yet totally ignored!):


Don’t use a password here that you use for anything else as it is stored here in plain text! To revoke a user’s access remove their line from the file. Restart deluged for the new config to take effect (sudo systemctl restart deluged)

To configure your client (these instructions are the same for both the Linux and Windows clients)

  • Start the client and in Preferences>Interface untick Classic Mode
  • Restart your client and you should be presented with the Connection Manager
  • Click Add and add fill in the details of your OSMC box using the username and password you configured above. The port will be 58846.
  • If a green tick appears next to the connection then everything has worked, highlight it and press connect to use it.

Now your client is configured to use your OSMC box to download torrents, so torrents you add from your PC will actually be downloaded on your Raspberry Pi and you can switch your PC off without pausing the torrent.

#Web Interface#

In order to use the web interface (which also facilitates the use of mobile apps) it is necessary to install and configure the web interface separately. We installed the software at the start (deluge-web for on the local network and nginx to proxy it out to the wider world over SSL).

The web GUI doesn’t autostart by default so we need to create another systemd service for it.

sudo nano /etc/systemd/system/deluge-web.service and add the following text:

Description=Deluge Bittorent Web Interface





As before systemd needs to be made aware of the new files and then reloaded to pick up the new unit.

sudo systemctl daemon-reload
sudo systemctl enable deluge-web.service

Now start and check the web service with:

sudo systemctl start deluge-web
sudo systemctl status deluge-web

If it is “Active: active (running)” then great, if you see "Active: inactive (dead) on your systemctl status check then start the web-interface directly from the command line with sudo /usr/bin/deluge-web and monitor the command line while you point your browser at http://IP.OF.YOUR.OSMCBOX:8112/ and enter the password deluge. You will likely see that there is no green tick next to the connection for even though you know that deluged is running. Back at the command line you’ll see something like: “BadLoginError: Password does not match” and “RPCRequest: daemon.login(localclient, nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn)” (where all the n’s are numbers and letters). Ctrl+C will kill deluge-web and then you can copy this long string of numbers, stop deluged with sudo systemctl stop deluged and then sudo nano /var/lib/deluged/.config/deluge/auth and replace the long string of letters and numbers after localclient with the one you copied from the error (be sure to leave the : at either end). Now run the following to restart deluge and the web service sudo systemctl start deluged then sudo systemctl start deluge-web.

Check the status again and it should show “Active: active (running)”.

Now point a browser at http://IP.OF.YOUR.OSMCBOX:8112/ and enter the password deluge. You should see a green tick next to the connection for As it’s your first login the web interface will suggest you change your password, if you are going to make this accessible from the outside world (see later) then set something very strong here.

You can stop the connection box coming up every time by setting the “default_daemon” in the web.conf file:

sudo systemctl stop deluge-web
sudo nano /var/lib/deluged/.config/deluge/web.conf
change "default_daemon":"", to "default_daemon":"",
sudo systemctl start deluge-web

You now have a torrent server you can use with any number of deluge clients inside your network and a web interface you can also access anywhere inside your network. The next step is to make this available from outside so it is possible to add/check torrents on the go either with a browser or an app.

#External Access and Apps#

The first challenge is to expose the web interface as the apps depend on this for their json data feed.

The deluge web interface is capable of running natively over SSL but I’ve used nginx here as a reverse proxy as I want to be able to proxy other services throught the same port to my Pi and not be tied to just the one web service. In what follows deluge will be exposed on https://my.domain/torrent (so I can use https://my.domain/somethingelse for something else and use the same certificate).

I’m not going to go into the finer details of setting a static IP for your Pi, obtaining a domain and forwarding it to your Pi and installing Dynamic DNS services etc or how to forward port 443 to your Pi - there are other how tos already in this section on that that are far better than I could write. For the purposes of what follows I will presume you have a domain which points at your network and traffic is forwarded through your router to your RPi. If you don’t know how to do that try here -> [HowTo] Free .tk domain name that always points to your Pi or [HowTo] DDNS Mega Thread

Now you have that you need a certificate (you can generate your own but they you’ll be told it’s not safe by browsers and many of the apps will only accept certificates they can validate so we’ll use one from a trusted source. You can get these free for personal use from https://www.startssl.com/ or you can purchase from a supplier of your choice. Again I’m not going to go into detail here, there are many guides on the internet and there are no steps here that are bespoke for either the Pi, OSMC or Deluge.

Once you have the certificate you need the .crt file and the .key file (exactly how you retrieve these will depend on the provider you choose). Pop these onto your Pi and copy them to the /etc/nginx directory. Then we need to set up nginx, so start off by stopping the server sudo systemctl stop nginx and then edit the following config files.

Back up the default config, in case of a problem sudo mv /etc/nginx/sites-available/default /etc/nginx/sites-available/default.bak

Edit the file with sudo nano /etc/nginx/sites-available/default add the following text and change the bits between <<<>>> to represent your setup:

server {
        listen 80 default_server;
        listen [::]:80 default_server;
        return 301 https://$host$request_uri;

server {
        listen 443;
        listen [::]:443;

        ### http://www.gnuterrypratchett.com/ ###
        add_header X-Clacks-Overhead "GNU Terry Pratchett"; #<<<You can delete this line if you're not a Terry Pratchett fan>>>

        root /var/www/html;
        index index.php index.html index.htm index.nginx-debian.html;

        server_name <<<YOUR.DOMAIN>>>;

        ssl_certificate         /etc/nginx/<<<YOUR_CERT_FILE>>>.crt;
        ssl_certificate_key     /etc/nginx/<<<YOUR_KEY_FILE>>>.key;

        ssl on;
        ssl_session_cache  builtin:1000  shared:SSL:10m;
        ssl_protocols  TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
        ssl_prefer_server_ciphers on;

        access_log /var/log/nginx/access.log;

        location /torrent {
                proxy_set_header        X-Deluge-Base   "/torrent/";
                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-Forwarded-Proto $scheme;

                # Fix the “It appears that your reverse proxy set up is broken" error.
                proxy_pass          http://localhost:8112/;
                proxy_read_timeout  90;
                proxy_redirect          off;
                proxy_buffering         off;


        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        location ~ /\.ht {
                deny all;

The first server declaration redirects all non-secure http traffic around to https, the second configures the https proxy.

Fianlly restart nginx with sudo systemctl start nginx, and your torrent server will be available at “https://YOUR.DOMAIN/torrent”.

Congratulations, you should now have a torrent server which you can interface with from any machine on your local network with a torrent client or anywhere on the internet via a secure web site. One more step for ultimate functionality.

#Mobile App#

There are a number of mobile apps available but many of them are either poorly designed or lack a lot of basic features. The best I’ve found so far is Transdrone (http://www.transdroid.org) (I don’t have a fruity phone/tablet so can’t comment on the apps for those, but Transdroid is equally at home of phone or tablet on Android).

You can install if from Google Play and then you’ll need to add a new server to it, this is relatively straight forward, just follow the following options:

* Add new server
* Add normal, custom server
    Name: Whatever you like
    Server type: Deluge 1.2+
    IP or host name: YOUR.DOMAIN
    User name: <<<MUST BE LEFT BLANK>>>
    Password: <<<MUST BE LEFT BLANK>>>
    Deluge Web Password: <<<YOUR.STRONG.WEBGUI.PASSWORD>>>
    Advanced Settings:  Port Number: 443
                        Folder: /torrent
                        Use SSL: <<<TICK THIS>>>
                        Accept all SSM certificates: <<<MAY NEED TO TICK THIS DEPENDING ON YOUR CERT CHOICES>>>

Come back and back again and restart the app to connect. You can now add torrents to your OSMC box for download from your phone/tablet from anywhere in the world just be clicking the torrent/magnet link and selecting open with Transdrone.


I’ve never noticed a problem with watching local content whilst downloading torrents using the limits I’ve put in the config example above. However if you don’t have a fast internet connection I would recommend pausing torrents before trying to play streaming content. This is a great reason to have the app as it makes managing this easy from the couch!

Most of the information in this guide came from http://dev.deluge-torrent.org/wiki/UserGuide - I have just distilled the many various pages I used for my setup into one place for ease of reference and added the section on configuring the nginx proxy and mobile app.

I hope this is useful to someone.

1 Like

How do I use HTTPS (SSL) on the web server?
[HowTo] Compile & Install Deluge on OSMC

Hi, Iv followed this guide a few times, when setting up my Vero, and I always have an issue connecting to the Daemon from outside (i.e. not via localhost on the Vero itself)

If you have issues connecting follow these steps:

sudo apt-get install deluge-console
deluge-console connect username password
config -s allow_remote True
config allow_remote
sudo systemctl restart deluged

This should be in the App Store :slight_smile:



OSMC already has Transmission in the Store. You can install it in a few clicks and it’s ready to go. No need to mess with config files.

1 Like


Almost every private trackers do not allow Transmission as a client.



That’s simply not true. Transmission, Deluge and rtorrent are the most recognized and supported client’s to run on linux boxes out there. These clients are whitelisted ( allowed) by all the sites we do not speak of. At least those that matter

1 Like


This seems overly complex. If this is about accessing webUI of your torrent client (or any other type of service/app) remotely, from outside of your home network, simply use SSH tunneling. It is by far the most secure solution since it does not require you to open extra ports. And it’s suprisingly easy!

You simply use the same port you use for SSH.

It allows you to connect quickly via SSH but also add SSH tunneling. No need to open extra ports or expose your Torrents WebUI to the internet. Very easy and probably the safest, most secure method!

For Android devices, I would recommend Termius but there are plenty options. It’s like Putty but on a phone and more user friendly. After you connect via Termius app, you can access the webUI of Transmission (or Deluge, if you prefer) or use an app like Torrnado (which I highly prefer since it has way more options than the webUI of Transmission).