15.04.2023

Introduction§ 

Deluge is a software used to download torrents. While many torrent applications are client-only, Deluge is both a server and a client.

Deluge server setup§ 

The instructions to host a Deluge server, and setup a Deluge client can be found in the official documentation.

The location of the file holding the Deluge credentials may vary. By default, Deluge configuration is held in the home of the current user, however, it is not the same with a server setup. In my case, the configuration is found in /var/lib/deluge/.config/deluge/auth, and the downloaded torrents are stored in /var/lib/deluge/Downloads/.

Once deluge is set up, you must have a way to retrieve the torrent. If you have an ssh access to the server, using rsync works well. However, if you don’t have such access, or want to share your files with others, a webpage can be useful.

Nginx index page§ 

We will use the following configuration for our Nginx site. Here, we use a specific location, and a basic authentication, so adapt your configuration to your needs.

server {
	listen 80;
	listen [::]:80;

	server_name <name of your server, for instance example.net>;

	root /var/www/html; # this is for the generic location

	location / {
		try_files $uri $uri/ =404;
	}

    # This is the actual conf for Deluge
    # We assume it will be accessed via example.com/deluge-files
	location /deluge-files/ {
        # this is the folder containing the files downloaded by Deluge
		alias /var/lib/deluge/Downloads/;
		autoindex on; # this will allow to generate the index of files

        # Authentication : we want only users with the correct password
        # to access the page
		auth_basic "Restricted Content";
		auth_basic_user_file "/etc/nginx/.htpasswd";
	}
}

The creation of the .htpasswd file, which contains the users credentials is explained in the Nginx documentation.