# General Settings
bind =
SERVER.IP.ADDRESS
ip =
SERVER.IP.ADDRESS
port_range =
60450-60460
port_random = no
encoding_list = UTF-8
check_hash = no
directory = /home/
USERNAME/downloads
session = /home/
USERNAME/.rtorrent/session
encryption = allow_incoming,try_outgoing,enable_retry
peer_exchange = no
schedule = watch_directory,5,5,load_start=/home/
USERNAME/watch/*.torrent
schedule = low_diskspace,5,60,close_low_diskspace=500M
schedule = untied_directory,5,5,stop_untied=
# Throttle Settings
upload_rate = 0
download_rate = 0
min_peers = 1
max_peers = 256
min_peers_seed = 1
max_peers_seed = 256
max_uploads = 64
max_uploads_global = 64
max_downloads_global = 64
# Tracker Related Settings
enable_trackers = yes
use_udp_trackers = yes
dht = disable
# Extra Settings
#schedule = tied_directory,5,5,start_tied=
#schedule = untied_directory,5,5,close_untied=
#on_start = link1,"create_link=tied,,.started"
#on_stop = link1,"delete_link=tied,,.started"
#on_finished = link1,"create_link=tied,,.finished"
#on_erase = link1,"delete_link=tied,,.finished"
#schedule = low_diskspace,5,60,close_low_diskspace=500M
#schedule = ratio,60,60,"stop_on_ratio=1020,9000M,9000"
#on_erase = rm_complete,"execute=rm,-rf,--,$d.get_base_path="[/quote]
There are several options you will need to configure. They are marked in red. The other options listed can also be configured as you like. The port range you use is up to you but keep in mind that the default bittorrent port range is not permitted to be used on most trackers. Generally somewhere in between 49152 - 65535 will do for most private sites.
The text in 'Extra Settings' is commented out but there are some powerful commands you can add to rTorrent to customise it. Read more over at the author's
site.
The throttle settings are pretty much default and can be adjusted to suit your hardware and connection.
rutorrent
Now we will install rutorrent, a WebUI to rTorrent. There are several different web user interfaces available for rTorrent but I prefer rutorrent. You can check out
wtorrent,
rtgui and
ntorrent but I won't offer support for them.
Navigate to the directory that apache can see (the default is /var/www/) and grab the latest build of rutorrent.
Lets edit the rutorrent configuration file.
Quote:
|
# nano /var/www/rtorrent/config.php
|
Edit the line which includes RPC_TIME_OUT and change it to 15000. This simply cuts down on the number of messages which are logged to rutorrent about timeout requests (it can become annoying).
Next, edit the line starting with $scgi_host and change it to the same port as you set in the rTorrent configuration file. It is very important these numbers are the same and that you remember this number for later when we configure apache.
Updating & Patching
libtorrent & rTorrent
If a new release of rTorrent is released and you need/want to upgrade (make sure TehConnection has
whitelisted it first!) all you need to do is navigate to the source directory and update:
Quote:
|
# cd /usr/local/src/libtorrent/
|
Then follow the same steps as above to recompile and reinstall rTorrent (./autogen.sh, ./configure, make, make install, make clean...) Your settings and session data will not be erased as it is all saved in a different location.
rutorrent
If you ever need to update rutorrent you can simply issue these commands from the directory rutorrent is installed in (/var/www/rtorrent/):
Patching rutorrent
At times the developers and testers will find issues with rutorrent and issue a patch to correct it. These patches can often be useful and waiting for the next release takes a while.
This page shows how to add patches to software in Linux.
rutorrent Plugins
There are many plugins available for the rutorrent frontend which offer enhanced functionality. You can view these
here.
I'll update this guide as I experiment with them and recommend the better ones. If you have any experience with any of these plugins please PM me and I'll add extra info.
apache
Now we need to enable SCGI in apache. This is so rTorrent and rutorrent can communicate. There is a plugin for rutorrent which accomplishes this but I have not tested it and from what I have heard my method provides better performance for now. Copy over the SCGI mod to enable it in apache.
Quote:
|
# cp /etc/apache2/mods-available/scgi.load /etc/apache2/mods-enabled/scgi.load
|
We need to edit the httpd.conf file and enable the SCGI communication port.
Quote:
|
# nano /etc/apache2/httpd.conf
|
Add "SCGIMount /RPC2 127.0.0.1:
Same port as rTorrent & rutorrent" without the quotation marks and save and exit the file.
Restart apache so the changes take effect:
Quote:
|
# /etc/init.d/apache2 restart
|
Because we have been editing and creating files as root our file permissions will be slightly borked. Lets fix that.
Quote:
|
# chown USERNAME:USERNAME -R /home/USERNAME/
|
Quote:
|
# chmod 755 /var/www/rtorrent/
|
Open a new instance of PuTTY and login to your server as the user you created to run rTorrent. Once logged in start rTorrent with screen.
If you get an error "[screen is terminating]" there is most likely an error with the rTorrent configuration file or rTorrent itself. You can take a look at the file as your user by simply typing:
Lets take a look at that new rutorrent installation.
http://IP.ADDRESS.OF.YOUR.SERVER/rtorrent/ - If your host has given you a URL (some.server.net) then that will work as well.
If everything loads nicely then all has gone well.
Authentication
You might have noticed that we were able to browse directly to the rutorrent page without having to enter any kind of password. Unfortunately rutorrent does not have any kind of authentication system. To protect our WebUI we will need to make apache ask for a password.
On top of this I have also decided that I will explain how to use ssl for communicating with apache (https). This is because the username and password will be sent in clear text and anyone sniffing your packets will be able to grab the credentials otherwise.
First off, lets create ourselves a self-signed certificate. We need this to use encryption but unfortunately browsers will throw up exceptions to self-signed certificates. There is nothing wrong with them it is just that they cannot be verified by a third party Certificate Authority (CA). You would do well to not trust any self-signed certificates unless you trust the website owner. Since that owner is yourself we are going to be OK.
Generate a key for the Certificate Signing Request (CSR):
Quote:
|
# openssl genrsa -des3 -out server.key 1024
|
You will need to enter a passphrase which cannot be shorter than four characters (ideally eight or more) that you must not forget. When we have finished every time you restart apache you will have to enter it.
Now we'll use our new key to create the CSR proper:
Quote:
|
openssl req -new -key server.key -out server.csr
|
You will be asked a lot of information and you can put whatever you'd like in the fields that follow.
Now we'll create the certificate:
Quote:
|
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
|
All we need to do now is to install the certificate and remove the other file.
Quote:
|
# mv server.crt /etc/ssl/certs/
|
Quote:
|
# mv server.key /etc/ssl/private/
|
Now we have a certificate we can enable mod_ssl in apache:
Quote:
|
# cp /etc/apache2/mods-available/ssl.load /etc/apache2/mods-enabled/
|
All that is left now is to configure ssl, set a password for our rTorrent directory in apache and we'll be using rutorrent encrypted!
Quote:
|
# nano /etc/apache2/sites-available/default
|
Quote:
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/
SSLEngine on
SSLOptions StrictRequire
SSLCertificateFile /etc/ssl/certs/server.crt
SSLCertificateKeyFile /etc/ssl/private/server.key
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options FollowSymLinks
AllowOverride None
Order allow,deny
allow from all
</Directory>
<Directory /var/www/rtorrent/>
Options FollowSymLinksIfOwnerMatch
AllowOverride None
Order allow,deny
allow from all
AuthUserFile /etc/apache2/private/.htpasswd
AuthGroupFile /dev/null
AuthName "A Server Name"
AuthType Basic
<Limit GET POST>
require user USERNAME
</Limit>
</Directory>
...
|
The file contines after the dots but all you need to edit is what is highlighted in red. Where you see 'USERNAME' you may pick any username you'd like. If you'd like multiple username/password pairs to be able to login then replace your desired username with 'valid-user' (without the quotation marks).
Lets create the password file and then reboot apache and see if its all running smoothly.
Quote:
|
# mkdir /etc/apache2/private
|
Quote:
|
# cd /etc/apache2/private
|
Quote:
|
# htpasswd -c .htpasswd USERNAME
|
htaccess will prompt you to enter and re-enter a password. If you want to add another user then enter the same command as before but don't type the "-c" part. That way you will simply add another user to the same file.
Quote:
|
# /etc/init.d/apache2 restart
|
apache will ask you for your passkey which we created when we created the certificate. Now we'll browse to the new and improved encrypted version of your server.
https://IP.ADDRESS.OF.YOUR.SERVER/rtorrent/
vnStat
vnStat is a handly little program which keeps a record of your bandwidth usage by the server. It works by monitoring the network interface and can display the statistics via the commandline even in realtime.
This is useful to us but for those who can't be bothered firing up PuTTY for something like this there is a useful little frontend you can install so you can monitor bandwidth from your browser.