233 lines
9.7 KiB
Markdown
233 lines
9.7 KiB
Markdown
|
---
|
||
|
title: "Setting up a ruTorrent seedbox"
|
||
|
date: 2016-10-14T17:04:24+02:00
|
||
|
slug: "setting-up-a-rutorrent-seedbox"
|
||
|
image: /content/images/2016/10/Screenshot-header-scaled.png
|
||
|
---
|
||
|
|
||
|
I'm not much for writing guides. But I'll have to make an exception for this one, the number of people who ask me for help is just too high. I'll assume you already know what a seedbox is if you're reading this.
|
||
|
|
||
|
Please note that if you don't need the full power of the Linux command line, you're probably better off with a shared seedbox plan. These are managed seedboxes that come pre-configured and are ready to download/seed.
|
||
|
|
||
|
If you're looking for a shared host, I recommend [Bytesized](http://bytesized-hosting.com/plans) or [WhatBox](https://whatbox.ca/plans). I will be looking at Ubuntu servers since those are the most common these days. You will need a 16.04 server. Older versions of Ubuntu have an rtorrent version that is not compiled with the options we need. (Of course you could compile it yourself, but if you know how to do that, then why do you need this guide?)
|
||
|
|
||
|
If you adapt the package manager commands, you might get this working on a lot of other distros as well.
|
||
|
|
||
|
With that out of the way, let's get on with the rest:
|
||
|
|
||
|
# Finding a server
|
||
|
|
||
|
Many people start here believe it or not. They can't find a server that fits their needs. Especially since the VPS market usually doesn't provide enough hard drive space and dedicated servers are too expensive. I'll be looking at HDD servers for now. If you need a beefy SSD server to handle loads of seeding, you probably (read: hopefully) know what you're getting into already.
|
||
|
|
||
|
If possible, I recommend you skip using a VPS entirely. You can get dedicated servers from [Online.net](https://www.online.net/en/dedicated-server) for as little as 8.99€/month, or 4.99€/month from [Kimsufi](https://www.kimsufi.com/uk/servers.xml) (Though Kimsufi are often out of stock). The problem with dedicated servers is that they usually have high setup fees, which many users just can't swallow at first. You also have to pay monthly, which isn't too nice if you only need a seedbox for a little while (eg. When you're on vacation and your hotel's network blocks torrenting)
|
||
|
|
||
|
If you really can't swallow the setup fee (I feel you students) or only need your seedbox for a short period of time, try [Vultr](https://www.vultr.com/). These have 125 GB plans that are billed hourly, $5/month if you keep it running the entire month. However keep in mind that VPS hosts will often suspend you for torrenting using public trackers (If you don't know if you're using a private tracker or a public tracker, you're definitely using a public one). Dedicated hosts will usually just forward claims to you and kindly ask you to stop seeding that torrent. VPS hosts also have stricter bandwidth limits.
|
||
|
|
||
|
Now hopefully this helped you find a server that you're happy with. If not, you can try pinging me on Twitter and I'll give you some tips.
|
||
|
|
||
|
# Installing the applications
|
||
|
|
||
|
To get started, we'll be installing the actual applications we need.
|
||
|
|
||
|
## rtorrent
|
||
|
|
||
|
Before the start, type `cd ~` to make sure that you're in your home directory.
|
||
|
|
||
|
First off we'll start by installing rtorrent. Since Ubuntu 16.04 includes a version compiled with SCGI support, you just have to run this command:
|
||
|
|
||
|
```
|
||
|
sudo apt install rtorrent
|
||
|
```
|
||
|
|
||
|
If you have the knowledge, I recommend running rtorrent as a separate user, I won't be covering that here though.
|
||
|
|
||
|
And there you go. Now you have rtorrent installed. Next up we're going to run the command `nano .rtorrent.rc` - You are now editing the config file that rtorrent will be using. You can now paste in this config (That I've gone ahead and commented for curious users)
|
||
|
|
||
|
```
|
||
|
# Maximum and minimum number of peers to connect to per torrent.
|
||
|
# rtorrent will connect aggressively until it reaches the minimum,
|
||
|
# but stop connecting to new clients when it reaches max.
|
||
|
min_peers = 40
|
||
|
max_peers = 150
|
||
|
|
||
|
# Same as above but for seeding completed torrents (-1 = same as downloading)
|
||
|
min_peers_seed = 250
|
||
|
max_peers_seed = 5000
|
||
|
|
||
|
# Maximum number of simultaneous uploads per torrent.
|
||
|
max_uploads = 30
|
||
|
|
||
|
# Default directory to save the downloaded torrents.
|
||
|
directory = ~/downloads
|
||
|
|
||
|
# Session folder used by rtorrent to store current data
|
||
|
session = ~/.session
|
||
|
|
||
|
# Stop torrents when diskspace is low.
|
||
|
schedule = low_diskspace,5,60,close_low_diskspace=10240M
|
||
|
|
||
|
# Port range to use for listening.
|
||
|
port_range = 55965-55970
|
||
|
|
||
|
# Start opening ports at a random position within the port range.
|
||
|
port_random = yes
|
||
|
|
||
|
# Check hash for finished torrents to confirm that the files are correct
|
||
|
check_hash = yes
|
||
|
|
||
|
# Set whether the client should try to connect to UDP trackers.
|
||
|
use_udp_trackers = yes
|
||
|
|
||
|
# Allow encrypted connection and retry with encryption if it fails.
|
||
|
encryption = allow_incoming,enable_retry,prefer_plaintext
|
||
|
|
||
|
# Disabled DHT and peer exchange. (You can remove this if you're only using public trackers)
|
||
|
dht = disable
|
||
|
peer_exchange = no
|
||
|
|
||
|
# Finally, the SCGI port rtorrent will be listening on, for communication via ruTorrent
|
||
|
scgi_port = 127.0.0.1:5040
|
||
|
```
|
||
|
|
||
|
Press Ctrl + X to save the file. To finish up, run these two commands:
|
||
|
|
||
|
```
|
||
|
mkdir .session
|
||
|
mkdir downloads
|
||
|
```
|
||
|
|
||
|
This will create the session directory that rtorrent needs to store its data, as well as the downloads directory to store torrents in.
|
||
|
|
||
|
We will now run rtorrent in a tmux session. This allows the application to keep running in the background after we disconnect from ssh.
|
||
|
|
||
|
Type `tmux new-session -s rtorrent` to start a new session in tmux, you'll know it's working if you see a colored bar at the bottom of your terminal, usually green by default. Similar to this:
|
||
|
|
||
|
![rtorrent screenshot](/content/images/2016/10/mintty_2016-10-06_13-39-29.png)
|
||
|
|
||
|
*(Ignore the "Could not read error" in the screenshot, you should not have that. I just have insanely strict permissions on my server)*
|
||
|
|
||
|
Type `rtorrent` to start the torrent client. You'll see a terminal user interface open up. Now you can press Ctrl+B, D to exit (That's Ctrl+B and then D afterwards, Not Ctrl, B and D all at once.)
|
||
|
|
||
|
Congratulations, we just set up rtorrent. If you're happy with a terminal interface, you could start using it right now. If you want to, you can use `tmux attach -t rtorrent` to open the tmux session again.
|
||
|
|
||
|
## Nginx
|
||
|
|
||
|
This is the web server we will be using. To install it, run `sudo apt install nginx apache2-utils php`. This also installs `apache2-utils`, we need this to password protect our ruTorrent interface later. It also installs PHP.
|
||
|
|
||
|
We can now configure the web server.
|
||
|
|
||
|
```
|
||
|
cd /etc/nginx/sites-available
|
||
|
```
|
||
|
|
||
|
First, we'll get rid of the default configuration:
|
||
|
|
||
|
```
|
||
|
sudo rm -rf default
|
||
|
```
|
||
|
|
||
|
Now you can run create a new configuration file:
|
||
|
|
||
|
```
|
||
|
sudo nano rutorrent
|
||
|
```
|
||
|
|
||
|
Paste in the following config:
|
||
|
|
||
|
```
|
||
|
# Forward PHP requests to php-fpm
|
||
|
upstream php-handler {
|
||
|
server unix:/run/php/php7.0-fpm.sock;
|
||
|
}
|
||
|
|
||
|
server {
|
||
|
listen 80 default_server;
|
||
|
|
||
|
root /var/www/rutorrent;
|
||
|
index index.php index.html;
|
||
|
|
||
|
server_name _;
|
||
|
|
||
|
# Send PHP files to our PHP handler
|
||
|
location ~ .php$ {
|
||
|
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||
|
fastcgi_pass php-handler;
|
||
|
fastcgi_index index.php;
|
||
|
include fastcgi.conf;
|
||
|
}
|
||
|
|
||
|
# Password authentication
|
||
|
location / {
|
||
|
auth_basic "Restricted";
|
||
|
auth_basic_user_file /var/www/rutorrent/.htpasswd;
|
||
|
}
|
||
|
}
|
||
|
```
|
||
|
|
||
|
*If you have a domain name I **highly** recommend that you look into setting up SSL with letsencrypt. The login will be sent over plaintext otherwise and only helps to keep people who happened to find your Web UI out.*
|
||
|
|
||
|
Again, press Ctrl+X to save this configuration.
|
||
|
|
||
|
Alright, finally, we have to enable the config. To do this we will set up a symbolic link (Sorta like a Windows shortcut I guess). To accomplish this, run the following command:
|
||
|
|
||
|
```
|
||
|
sudo ln -s /etc/nginx/sites-available/rutorrent /etc/nginx/sites-enabled/rutorrent
|
||
|
```
|
||
|
|
||
|
Finish up with one last command to make the changes take effect, and then we can move on to ruTorrent itself:
|
||
|
|
||
|
```
|
||
|
sudo service nginx reload
|
||
|
```
|
||
|
|
||
|
## ruTorrent
|
||
|
|
||
|
Alright, here's the king. Start by creating the web folder for ruTorrent and entering it:
|
||
|
|
||
|
```
|
||
|
sudo mkdir /var/www/rutorrent
|
||
|
cd /var/www/rutorrent
|
||
|
```
|
||
|
|
||
|
To install ruTorrent, we'll use git to download the files straight from GitHub:
|
||
|
|
||
|
```
|
||
|
git clone https://github.com/Novik/ruTorrent.git .
|
||
|
```
|
||
|
|
||
|
(Remember the period at the end, otherwise You'll get an extra subdirectory that we don't want.)
|
||
|
|
||
|
Now run sudo nano conf/config.php to edit the config file. Find the lines that say something like:
|
||
|
|
||
|
$scgi_port = 5000;
|
||
|
$scgi_host = "localhost";
|
||
|
|
||
|
And make sure they say:
|
||
|
|
||
|
$scgi_port = 5040;
|
||
|
$scgi_host = "127.0.0.1";
|
||
|
|
||
|
Now we will set up basic password protection with this command:
|
||
|
|
||
|
sudo htpasswd -c .htpasswd <username>
|
||
|
|
||
|
Obviously, replace <username> with the name you want to log in with. You will be prompted for a password. Unless you set up SSL by yourself earlier, this isn't very secure, so don't use a regular password that you login with elsewhere. Now we'll set the permissions for the web folder and the htpasswd file:
|
||
|
|
||
|
sudo chown -R :www-data /var/www/rutorrent
|
||
|
sudo chown :www-data /var/www/rutorrent/.htpasswd
|
||
|
sudo chmod -R 774 /var/www/rutorrent
|
||
|
sudo chmod 770 /var/www/rutorrent/.htpasswd
|
||
|
|
||
|
You might also want to add your own user to the www-data group. This will make it easier to work with any web-related files:
|
||
|
|
||
|
sudo adduser <username> www-data
|
||
|
|
||
|
Of course, replace the username.
|
||
|
|
||
|
And... Congratulations! Visit your server's IP address, and you should now be prompted for login. After that, you will see a fantastic stock ruTorrent interface. Well deserved.
|
||
|
|
||
|
If needed you might also want to install additional packages like `unzip`, `unrar`, `ffmpeg`, and `mediainfo`.
|
||
|
|
||
|
Tip: The theme in he header image is available [here](https://github.com/QuadPiece/club-quad) with install instructions.
|
||
|
|