本教程将向您展示如何在Ubuntu 20.04中安装uTorrent。对于想要通过域名访问uTorrent的用户,还包括有关在Ubuntu上自动启动uTorrent服务器以及如何使用Nginx / Apache Web服务器设置反向代理的说明。
Linux本机uTorrent客户端是基于Web的应用程序,这意味着您将在Web浏览器中使用uTorrent。该应用程序正式称为uTorrent服务器,具有以下特点:
- 分布式哈希表(DHT)
- UPnP端口映射
- NAT-PMP端口映射
- 上传速率限制
- 下载速率限制
- 排队
- 可配置的同时上传对等体数限制
- 增量文件分配
- 块级分拣
- 单独的线程用于文件检查和下载
- 单线程和单端口,可进行多个torrent下载
- BitTorrent扩展协议
- 多跟踪器扩展支持
- 公平贸易扩展
- 紧凑型追踪器扩展
- 快速恢复
- 种子文件排队-检查是否无法快速恢复
- HTTP种子支持
- 从其他BitTorrent客户端恢复部分下载
- 文件大小大于2GB
- 选择性下载多文件种子
- IPv6
- 高性能网络堆栈
- uTP –具有动态拥塞控制的基于UDP的高级传输
适用于Linux的uTorrent的最新版本是针对Ubuntu 13.04发布的,但是我们仍然可以在Ubuntu 20.04 LTS中运行它。转到uTorrent Linux下载页面,下载适用于Ubuntu 13.04的uTorrent服务器软件包。
下载地址为:
https://www.utorrent.com/downloads/linux
或者,您可以打开一个终端窗口,然后运行以下命令从命令行下载它。 64位 - wget http://download-hr.utorrent.com/track/beta/endpoint/utserver/os/linux-x64-ubuntu-13-04 -O utserver.tar.gz
复制代码 32位- wget http://download-hr.utorrent.com/track/beta/endpoint/utserver/os/linux-i386-ubuntu-13-04 -O utserver.tar.gz
复制代码 下载后,将工作目录更改为下载uTorrent服务器文件的目录。然后运行以下命令将tar.gz文件提取到/opt/目录。
- sudo tar zxvf utserver.tar.gz -C /opt/
复制代码 接下来,通过执行以下命令来安装所需的依赖项。
- sudo apt install libssl-dev -y
- wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl1.0/libssl1.0.0_1.0.2n-1ubuntu5.3_amd64.deb
- sudo apt install ./libssl1.0.0_1.0.2n-1ubuntu5.3_amd64.deb
复制代码
安装依赖项后,创建一个符号链接。- sudo ln -s /opt/utorrent-server-alpha-v3_3/utserver /usr/bin/utserver
复制代码
使用以下命令启动uTorrent服务器。默认情况下,uTorrent服务器侦听0.0.0.0:8080。如果还有另一个服务也在端口8080上侦听,则应暂时停止该服务。uTorrent也将使用端口10000和6881。该-daemon选项将使uTorrent服务器在后台运行。
- utserver -settingspath /opt/utorrent-server-alpha-v3_3/ -daemon
复制代码 现在,您可以通过在Web浏览器地址栏中键入以下文本来访问浏览器中的uTorrent Web UI。如果要在本地计算机上安装uTorrent,请替换your-server-ip为localhost。
- http://localhost:8080/gui
复制代码 如果Ubuntu服务器上有防火墙,则需要允许访问端口8080和6881。例如,如果使用UFW,请运行以下两个命令打开端口8080和6881。
- sudo ufw allow 8080/tcp
- sudo ufw allow 6881/tcp
复制代码 请注意,网址后面一定要加/gui,否则您将遇到无效的请求错误。当要求输入用户名和密码时,admin在用户名字段中输入密码,密码为空。
登录后,您应该通过单击齿轮图标,然后Web UI在左侧菜单上选择来更改管理员密码。您可以更改用户名和密码,这比用作用admin户名更安全。
如果在端口8080上有其他服务正在侦听,则在本Connectivity节中,可以将uTorrent侦听端口更改为其他端口,例如8081。更改端口后,必须使用以下命令重新启动uTorrent服务器。
- sudo pkill utserver
- utserver -settingspath /opt/utorrent-server-alpha-v3_3/ &
复制代码
开机启动uTorrent
要启用自动启动,我们可以使用以下命令创建systemd服务。
- sudo vi /etc/systemd/system/utserver.service
复制代码 将以下文本放入文件中。请注意,由于我们将使用systemd启动uTorrent,因此-daemon在start命令中不需要该选项。
- [Unit]
- Description=uTorrent Server
- After=network.target
- [Service]
- Type=simple
- User=utorrent
- Group=utorrent
- ExecStart=/usr/bin/utserver -settingspath /opt/utorrent-server-alpha-v3_3/
- ExecStop=/usr/bin/pkill utserver
- Restart=always
- SyslogIdentifier=uTorrent Server
- [Install]
- WantedBy=multi-user.target
复制代码 然后保存退出,重启daemon
- sudo systemctl daemon-reload
复制代码 不建议以root用户身份运行uTorrent服务器,因此我们在服务文件中指定了uTorrent服务器应以utorrent用户和组身份运行,但没有root特权。utorrent使用以下命令创建系统用户和组。
- sudo adduser --system --group utorrent
复制代码 接下来,停止当前的uTorrent服务器。
使用systemd服务启动uTorrent服务器。
- sudo systemctl start utserver
复制代码 在启动系统时启用自动启动。
- sudo systemctl enable utserver
复制代码 现在检查utserver状态。
- systemctl status utserver
复制代码 我们可以看到已启用自动启动,并且uTorrent服务器正在运行。创建utorrent用户时,还会在创建主目录/home/utorrent/。建议您将此主目录设置为torrent下载目录,因为utorrent用户具有写许可权。我们还需要/opt/utorrent-server-alpha-v3_3/通过执行以下命令使utorrent成为目录的所有者。- sudo chown utorrent:utorrent /opt/utorrent-server-alpha-v3_3/ -R
复制代码 到目前为止,utorrent已经安装完成。
以下是高级设置,可以设置Apache和Nginx的反向代理设置,非必须项
如果要使用域名从远程连接访问uTorrent服务器,可以设置Nginx反向代理。第一种:子目录配置
如果您的Ubuntu服务器已经有Nginx服务的网站,那么您可以配置现有的Nginx服务器块,以便可以从域名的子目录访问uTorrent Web UI。- sudo vi /etc/nginx/conf.d/your-website.conf
复制代码 在服务器块中,粘贴以下指令。如果您之前更改过端口,那么您也需要在此处更改它。
- location /gui {
- proxy_pass http://localhost:8080;
- proxy_set_header Host $http_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;
- }
复制代码 保存并关闭文件。然后测试Nginx配置。
如果测试成功,请重新加载Nginx。
- sudo systemctl reload nginx
复制代码 现在您可以通过访问uTorrent Web UI
第二种:二级域名配置
如果您在Ubuntu服务器上没有现有的网站,则必须创建一个新的空间来存储文件。在Ubuntu 20.04或Ubuntu 19.04上安装Nginx。
启动Nginx Web服务器
- sudo systemctl start nginx
复制代码 然后在/etc/nginx/conf.d/目录中创建一个新的网站配置文件。
- sudo vi /etc/nginx/conf.d/utserver-proxy.conf
复制代码 将以下文本粘贴到文件中,并且utorrent.your-domain.com部分用自己的域名替换,不要忘记为其创建A记录。
- server {
- listen 80;
- server_name utorrent.your-domain.com;
- error_log /var/log/nginx/uttorrent.error;
- location /gui {
- proxy_pass http://localhost:8080;
- proxy_set_header Host $http_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;
- }
- }
复制代码 然后保存退出。
然后测试Nginx配置。
如果测试成功,请重新加载Nginx。
- sudo systemctl reload nginx
复制代码 现在您可以通过访问uTorrent Web UI。
- utorrent.your-domain.com/gui
复制代码
设置Apache反向代理如果您使用Apache Web服务器而不是Nginx,请按照以下说明设置反向代理。
安装Apache Web服务器。
要将Apache用作反向代理,我们需要启用proxy模块,并且还将启用rewrite模块。
- sudo a2enmod proxy proxy_http rewrite
复制代码 然后为uTorrent创建一个虚拟主机文件。
- sudo vi /etc/apache2/sites-available/utorrent.conf
复制代码 将以下配置放入文件中。utorrent.your-domain.com用您的实际域名替换,不要忘记为其设置A记录。
- <VirtualHost *:80>
- ServerName utorrent.your-domain.com
- RewriteEngine on
- RewriteRule ^/gui(/?)(.*)$ /$2 [PT]
- ProxyPreserveHost on
- ProxyPass / http://127.0.0.1:8080/gui/
- ProxyPassReverse / http://127.0.0.1:8080/gui/
- </VirtualHost>
复制代码 保存并关闭文件。然后启用此虚拟主机。
- sudo a2ensite utorrent.conf
复制代码 重新启动Apache,以使更改生效。
- sudo systemctl restart apache2
复制代码 现在,您可以通过utorrent.your-domain.com在浏览器地址栏中输入子域()来远程访问uTorrent服务器。如果未加载uTorrent Web UI,则可能需要删除默认的虚拟主机文件并重新启动Apache Web服务器。
启用HTTPS
为了加密HTTP流量,我们可以通过安装由Let's Encrypt发行的免费TLS证书来启用HTTPS。运行以下命令在Ubuntu 20.04或Ubuntu 19.04服务器上安装Let's Encrypt客户端(certbot)。
如果使用Nginx,则还需要安装Certbot Nginx插件。
- sudo apt install python3-certbot-nginx
复制代码 接下来,运行以下命令以获取并安装TLS证书。
- sudo certbot --nginx --agree-tos --redirect --hsts --staple-ocsp --email you@example.com -d utorrent.your-domain.com
复制代码
如果使用Apache,请安装Certbot Apache插件。
- sudo apt install python3-certbot-apache
复制代码 并运行此命令获取并安装TLS证书。
- sudo certbot --apache --agree-tos --redirect --hsts --staple-ocsp --email you@example.com -d utorrent.your-domain.com
复制代码 解释说明:
- --nginx: Use the nginx plugin.
- --apache: Use the Apache plugin.
- --agree-tos: Agree to terms of service.
- --redirect: Force HTTPS by 301 redirect.
- --hsts: Add the Strict-Transport-Security header to every HTTP response. Forcing browser to always use TLS for the domain. Defends against SSL/TLS Stripping.
- --staple-ocsp: Enables OCSP Stapling. A valid OCSP response is stapled to the certificate that the server offers during TLS.
现在应该获得证书并自动安装。
现在,您应该可以通过访问uTorrent服务器https://utorrent.your-domain.com/gui。
如何在Ubuntu上卸载uTorrent
要删除uTorrent,请先停止当前的uTorrent进程。
然后删除安装目录。
- sudo rm -r /opt/utorrent-server-alpha-v3_3/
复制代码 并删除符号链接。
- sudo rm /usr/bin/utserver
复制代码
|