OS: Ubuntu 18.04 Apache/2.4.18 1.0.2g-1ubuntu4.10
Aim: to install Aria2 with WebUI and secure Token.
IP Addr of your Aria2 server is 192.168.0.111
Your local IP network is 192.168.0.0/24
Install aria2 package:
sudo apt install aria2
a. create Token:
openssl rand -base64 32
b. Create and edit configuration file (I created it in user folder /home/user/.aria2/aria.conf file, at least few lines must be added:
dir=/home/user/torrents #Or other directory to save downloads
rpc-secret=YOUR TOKEN FROM ABOVE
enable-rpc=true
rpc-listen-all=true
daemon=true
rpc-certificate=/usr/local/etc/aria2/aria2.pfx #your Certificate file
rpc-secure=true #enable encryption
Optional:
rpc-listen-port=6800
listen-port=6801 #for torrents
dht-listen-port=6801 #for torrents
c. Create PFX certificate. Please, leave "Password" field empty when it's prompted:
cd /usr/local/etc/aria2
sudo openssl req -x509 -nodes -days 3650 -newkey rsa:1024 -keyout aria2.pem -out aria2.pem
sudo openssl pkcs12 -export -out aria2.pfx -in aria2.pem -name "Aria2 Certificate"
sudo chmod 604 aria2.pfx
dir=/home/user/torrent
file-allocation=trunc
continue=true
daemon=true
##
log=/home/user/.aria2/aria2.log
console-log-level=warn
log-level=notice
##
max-concurrent-downloads=5
max-connection-per-server=5
min-split-size=20M
split=4
disable-ipv6=true
##
input-file=/home/user/.aria2/aria2.session
save-session=/home/user/.aria2/aria2.session
save-session-interval=30
##
enable-rpc=true
rpc-allow-origin-all=true
rpc-listen-all=true
rpc-listen-port=6800 #Port for JSON RPC
rpc-secret=YOUR TOKEN FROM ABOVE
rpc-certificate=/usr/local/etc/aria2/aria2.pfx #your Certificate file
rpc-secure=true #enable encryption
##
follow-torrent=mem
follow-metalink=mem
enable-dht6=false
peer-id-prefix=-TR2770-
user-agent=Transmission/2.77
seed-time=0
#seed-ratio=1.0
bt-seed-unverified=true
bt-save-metadata=true
bt-force-encryption=true
listen-port=6801 #Torrent TCP port
dht-listen-port=6801 #Torrent UDP port
d. If you have iptables add something like this:
iptables -I INPUT -p tcp -m tcp --dport 6800:6801 -j ACCEPT
iptables -I INPUT -p udp -m udp --dport 6801 -j ACCEPT
e. Start Aria2 and set configuration location:
aria2c --conf-path="/home/user/.aria2/aria2.conf"
you have to add it to the trusted list. Point browser to https://YOUR_SERVER_IP:6800/jsonrpc, e.g.:
https://192.168.0.111:6800/jsonrpc
and click "add this site to trusted, permanently".
cd /tmp
wget https://github.com/ziahamza/webui-aria2/archive/master.zip
unzip master.zip -d /var/www/
sudo nano /var/www/webui-aria2-master/configuration.js
change following lines:
host: location.protocol.startsWith('https') ? location.hostname : '192.168.0.111',
path: '/jsonrpc',
port: 6800,
encrypt: true,
auth: { // either add the token field or the user and pass field, not both.
// token: '$YOUR TOKEN FROM ABOVE$'
cd /etc/apache2/sites-available/
sudo nano 002-aria2.conf
with following text to enable you local LAN only:
<IfModule alias_module>
Alias /webui-aria2 /var/www/webui-aria2-master
<Directory "/var/www/webui-aria2-master">
AllowOverride None
Options None
Order deny,allow
Allow from 192.168.0.0/24 localhost 127.0.0.1
Deny from all
</Directory>
</IfModule>
sudo ln -s 002-aria2.conf ../sites-enabled
or
sudo a2ensite 002-aria2.conf
sudo service apache2 restart
You can call your Aria WebUI under e.g. http(s)://192.168.0.111/webui-aria2
sudo nano /lib/systemd/system/aria2.service
with following text:
[Unit]
Description=Aria2c download manager
Requires=network.target
After=dhcpcd.service
[Service]
Type=forking
User=user
Group=samegroup
ExecStart=/usr/bin/aria2c --conf-path=/home/user/.aria2/aria2.conf
WorkingDirectory=/home/user/torrents
ExecReload=/usr/bin/kill -HUP $MAINPID
RestartSec=1min
Restart=on-failure
[Install]
WantedBy=multi-user.target