从零开始自主搭建全套 Seedbox 环境 (1) - 下载篇

Rhilip 2018-02-01 PM 13283℃ 3条

感谢 @MMRlove 以成本价为我提供了新的保种盒子(虽然还是100M的KS-2E),既然是新盒子的话,不如尝试下新的东西,然后试了下有名的QuickBox,然而以Apache作为WEB服务的配置让我这个习惯lnmp环境的感觉到了极大的不适,而且部分链接仍然使用ip的形式来访问(即使使用Let's Encrypt脚本将其替换成域名形式,也是只是部分改成了<domain>:<port>,这样我没法用Cloudflare的CDN加速呀!!!),此外QuickBox对于系统的bash环境改动过大,个人不是很喜欢。而原先使用rtinst脚本因为大幅改进导致我再次使用极不习惯。此外两个脚本默认都是不带ipv6-patch的rutorrent,后面去重新打补丁编译更麻烦,不如自己直接配置方便。

系统配置及安装软件

  • Ubuntu 16.04
  • BBR
  • Nginx with module fancyindex
  • rTorrent + ruTorrent 0.9.4 with libtorrent 0.13.4 (with IPv6 patch and autodl-irssi)
  • Transmission
  • Deluge
  • qBitorrent
  • ffmpeg
  • webmin

这是一篇很长很长的文章,所以我还没写完Orz,另请注意,这是搭建我使用顺手的Seedbox环境,并不一定适用于所有用户。同时目前使用的一些资源来自多处,以后会慢慢整理成一个合适的repo放在Github上。

准备工作

准备工作主要做更改sshd服务,使用自定义用户名及密码登陆服务器而不是使用默认的root账户。并将所有资源存在以这个账号的根目录下。

安装BBR

BBR是Google开源的TCP拥塞控制算法,并能提升网速,这里直接使用来自秋水逸冰的一键脚本来安装。(因为这不是我们的重点工作2333,然而其实百兆管优化效果。。。

wget --no-check-certificate https://github.com/teddysun/across/raw/master/bbr.sh && chmod +x bbr.sh && ./bbr.sh

等脚本跑完,如果系统的Linux内核已经大于4.9会直接启用,如果小于的话,会更新内核到最新的内核,然后reboot检查是不是正常开启即可

更新软件源并安装必备软件

在这一步我们安装了php7.0环境以及编译环境,以及Nginxffmpegmediainfo等软件

apt-get update && apt-get upgrade
apt-get install -y sudo nano screen curl wget git rar unrar zip unzip build-essential php7.0-json libarchive-zip-perl libncurses5-dev php7.0-fpm patch ncurses-term php7.0-mbstring htop libtool libcurl3 php7.0-xmlrpc zlib1g-dev aptitude dtach libjson-perl libjson-rpc-perl comerr-dev build-essential libcurl4-openssl-dev libxml2-dev libperl-dev libjson-xs-perl libcppunit-dev libterm-readline-gnu-perl libevent-dev screen libnet-ssleay-perl subversion pkg-config ca-certificates php7.0-cli php7.0 software-properties-common libxml-libxml-perl irssi cfv libhtml-parser-perl intltool libdigest-sha-perl php-xml sudo ncurses-base python-scgi php7.0-dev php7.0-curl php7.0-mcrypt autoconf python-software-properties ntp libsigc++-2.0-dev g++ apache2-utils libssl-dev libcloog-ppl-dev libxml-libxslt-perl gcc php-geoip texinfo ffmpeg mediainfo nginx-extras perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl apt-show-versions python

请注意,以下所有步骤的依赖均在此步解决
默认是已经安装了sudo服务,如果没有的话可以apt-get install sudo来安装。

如果对于vi操作不习惯可以使用nano来替代,使用apt-get install nano来安装。并将后面的vi操作替换成nano

Nginx简单配置

这里只是简单的初步设置,对于不同软件的proxy我将在具体安装的过程中说明。同样,我将在所有配置完成后对Nginx设置做进一步优化。

  1. 创建Htpasswd文件(用于用户认证)

    这里偷懒直接用Online Gen就行 http://www.htaccesstools.com/htpasswd-generator/ 。输入账号密码,然后直接复制生成的内容就行保存到 /etc/nginx/.htpasswd 即可

  2. 自签Https证书

    自签一个https证书来使用。(因为到时候会用Cloudflare CDN,所以自签一个不会有很大影响)

  3. -p /etc/ssl/
  4. genrsa -des3 -out /etc/ssl/seedbox.key 1024
  5. req -new -key /etc/ssl/seedbox.key -out /etc/ssl/seedbox.csr
  6. rsa -in /etc/ssl/seedbox.key -out /etc/ssl/seedbox.nopass.key
  7. x509 -req -days 365 -in /etc/ssl/seedbox.csr -signkey /etc/ssl/seedbox.nopass.key -out /etc/ssl/seedbox.crt

  8. 编辑 vi /etc/nginx/sites-enabled/default 默认配置文件,找到并将有关php的设置改为以下内容,让Nginx支持了php。对于这一个配置文件,我们后面将再做更改。然后没问题可以使用 service nginx reload 重载配置文件。

  9. ~ .php$ {
    include snippets/fastcgi-php.conf;

    With php7.0-cgi alone:

    fastcgi_pass 127.0.0.1:9000;

    With php7.0-fpm:

    fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }

增加用户账户

请将<username>(ssh登陆的sudo账号名,最好使用全小写字母)替换成你需要的登陆用户名,并按照操作操作。

adduser <username>

adduser.jpg

输入visudo赋予新账号超级用户权限。在新出现的页面中找到原有的root位置,并添加账号信息。保存退出。

# User privilege specification
root    ALL=(ALL:ALL) ALL
<username>    ALL=(ALL:ALL) ALL

修改sshd设置:vi /etc/ssh/sshd_config

  • 修改默认的ssh端口为任意值,可以使用<10001-65535>中的任一值。(QuickBox默认使用4747,rtinst会使用21000-29000)
  • 禁止root账号登陆,并允许新账号登陆。
  • 禁用 x11 forwardingDNS

需要找到修改配置

Port <10001-65535>
PermitRootLogin no
X11Forwarding no

需要在默认配置中新增

UseDNS no
AllowUsers <username>

确认全部设置完成使用service ssh reload重启ssh服务,并在本地重新开一个ssh窗口,如果使用信息可以正常登陆的话,关掉原有的root窗口,之后我们将使用sudo提权的方式来配置系统环境,如果不行的话,请检查之前配置。

编译安装支持IPv6的rTorrent

安装XML-RPC

Homepage: http://xmlrpc-c.sourceforge.net/

XML-RPC is a quick-and-easy way to make procedure calls over the Internet. It converts the procedure call into an XML document, sends it to a remote server using HTTP, and gets back the response as XML.

下载xmlrpc源码包,编译安装。

svn co https://svn.code.sf.net/p/xmlrpc-c/code/stable /tmp/xmlrpc-c
cd /tmp/xmlrpc-c
./configure --disable-libwww-client --disable-wininet-client --disable-abyss-server --disable-cgi-server
make
sudo make install

安装libtorrent(0.13.4)并安装IPv6-patch

LibTorrent is the library on which the rTorrent client runs.

Before beginning this section, navigate to http://rakshasa.github.io/rtorrent/ in your browser to find the latest version of the library. Update the filename in the commands below to account for the version of LibTorrent you'd like to use. Make sure any communities you belong to have the torrent client you choose to use whitelisted.

在这一步中,我们将libtorrent的源码包下载到/tmp目录下,并打上IPv6补丁编译。

cd /tmp
curl http://rtorrent.net/downloads/libtorrent-0.13.4.tar.gz | tar xz
cd libtorrent-0.13.4
wget https://github.com/QuickBox/QB/raw/master/setup/sources/libtorrent-0.13.4-tar.patch
patch -p1 < libtorrent-0.13.4-tar.patch
./autogen.sh
./configure --enable-ipv6
make
sudo make install

安装rtorrent

Just as with the previous section, navigate to http://rakshasa.github.io/rtorrent/ in your browser to find the latest version of the client. Update the filename in the commands below to account for the version of rTorrent you'd like to use. Make sure any communities you belong to have the torrent client you choose to use whitelisted.

在这一步中,我们将下载rtorrent的源码包到/tmp目录下,并打上IPv6补丁编译。

cd /tmp
curl http://rtorrent.net/downloads/rtorrent-0.9.4.tar.gz | tar xz
cd rtorrent-0.9.4
wget https://github.com/QuickBox/QB/raw/master/setup/sources/rtorrent-0.9.4-tar.patch
patch -p1 < rtorrent-0.9.4-tar.patch
./autogen.sh
./configure --with-xmlrpc-c --enable-ipv6
make
sudo make install
sudo ldconfig

配置rtorrent

创建rtorrent相关目录(下载存储目录、watch目录),并修改相关权限

mkdir -p /home/<username>/rtorrent/{.session,watch,downloads}

使用vi ~/.rtorrent.rc编辑配置文件将以下修改arakasi72/rtinst/conf/rtorrent.rc 的信息粘贴进去。(请注意替换<username>,共2处

# This is the rtorrent configuration file installed by rtinst script - https://github.com/arakasi72/rtinst
# This file is installed to ~/.rtorrent.rc
# Enable/modify the options as needed, uncomment the options you wish to enable.
# This configuration will work with most systems, but optimal settings are dependant on specific server setup

### Set Directories
method.insert = cfg.basedir,     private|const|string, (cat,"/home/<username>/rtorrent/")
method.insert = cfg.watch,       private|const|string, (cat,(cfg.basedir),"watch/")

#method.insert = cfg.logs,       private|const|string, (cat,(cfg.basedir),"log/")
#method.insert = cfg.logfile,    private|const|string, (cat,(cfg.logs),"rtorrent-",(system.time),".log")

session.path.set = (cat,(cfg.basedir),".session")
directory.default.set = (cat,(cfg.basedir),"downloads")

schedule = watch_directory,5,5,((load.start,(cat,(cfg.watch),"*.torrent")))
schedule = low_diskspace,5,60,close_low_diskspace=10240M

### BitTorrent
# Global upload and download rate in KiB, `0` for unlimited
throttle.global_down.max_rate.set = 0
throttle.global_up.max_rate.set = 0

# Maximum number of simultaneous downloads and uploads slots
throttle.max_downloads.global.set = 150
throttle.max_uploads.global.set = 150

# Maximum and minimum number of peers to connect to per torrent while downloading
throttle.min_peers.normal.set = 30
throttle.max_peers.normal.set = 150

# Same as above but for seeding completed torrents (seeds per torrent)
throttle.min_peers.seed.set = -1
throttle.max_peers.seed.set = -1

### Networking
network.port_range.set = 51001-51250
network.port_random.set = yes
dht.mode.set = disable
protocol.pex.set = no
trackers.use_udp.set = yes

# network.scgi.open_port = localhost:5000
network.scgi.open_port = 127.0.0.1:5000
network.http.ssl_verify_peer.set = 0
protocol.encryption.set = allow_incoming,enable_retry,prefer_plaintext

network.max_open_files.set = 51200
network.max_open_sockets.set = 1536
network.http.max_open.set = 48
network.send_buffer.size.set = 4M
network.receive_buffer.size.set = 4M

### Memory Settings
pieces.hash.on_completion.set = no
pieces.preload.type.set = 1
pieces.memory.max.set = 3500M

### Logging:
#   Levels = critical error warn notice info debug
#   Groups = connection_* dht_* peer_* rpc_* storage_* thread_* tracker_* torrent_*
#print = (cat,"Logging to ",(cfg.logfile))
#log.open_file = "log", (cfg.logfile)
#log.add_output = "info", "log"
#log.add_output = "tracker_debug", "log"


### The following line initialises rutorrent plugins without needing to open the web interface
execute = {sh,-c,/usr/bin/php /var/www/rutorrent/php/initplugins.php <username> &}

#EOF

完成后使用rtorrent检查是否能正确进入rtorrent页面。如果没有任何报错信息的话,直接使用ctrl+Q返回退出。

rotrrent-cli.jpg

安装Rutorrent

  1. 下载Rutorrent源码包

  2. /var/www/html
  3. git clone https://github.com/Novik/ruTorrent.git rutorrent
  4. rm -rf rutorrent/plugins
  5. svn checkout https://github.com/Novik/ruTorrent/trunk/plugins rutorrent/plugins

  6. 配置Rutorrent

    1. 添加软件夹权限
sudo chown -R www-data:www-data rutorrent
sudo chmod -R 755 rutorrent
  1. 修改配置文件sudo vi rutorrent/conf/config.php,并更改以下项
     $log_file = '/tmp/rutorrent_errors.log';
     $topDirectory = '/home/<username>/rtorrent';
     $pathToExternals = array(
         "php" => '/usr/bin/php',
         "curl" => '/usr/bin/curl',
         "gzip" => '/bin/gzip',
         "id" => '/usr/bin/id',
         "stat" => '/usr/bin/stat',
     );
  1. 修改启用插件

    备份原有插件信息

sudo mv /var/www/html/rutorrent/conf/plugins.ini /var/www/html/rutorrent/conf/plugins.ini.backup
sudo vi /var/www/html/rutorrent/conf/plugins.ini

复制以下内容并保存退出

;; Plugins permissions.
;; If flag is not found in plugin section, corresponding flag from "default" section is used.
;; If flag is not found in "default" section, it is assumed to be "yes".
;;
;; For setting individual plugin permissions you must write something like that:
;;
;; [ratio]
;; enabled = yes ;; also may be "user-defined", in this case user can control plugins state from UI
;; canChangeToolbar = yes
;; canChangeMenu = yes
;; canChangeOptions = no
;; canChangeTabs = yes
;; canChangeColumns = yes
;; canChangeStatusBar = yes
;; canChangeCategory = yes
;; canBeShutdowned = yes

[default]
enabled = user-defined
canChangeToolbar = yes
canChangeMenu = yes
canChangeOptions = yes
canChangeTabs = yes
canChangeColumns = yes
canChangeStatusBar = yes
canChangeCategory = yes
canBeShutdowned = yes



[_getdir]
enabled = yes

[_task]
enabled = yes

[autotools]
enabled = user-defined

[chat]
enabled = no

[check_port]
enabled = no

[chunks]
enabled = user-defined

[cookies]
enabled = user-defined

[cpuload]
enabled = user-defined

[create]
enabled = user-defined

[data]
enabled = user-defined

[datadir]
enabled = yes

[diskspace]
enabled = user-defined

[edit]
enabled = user-defined

[erasedata]
enabled = user-defined

[extratio]
enabled = user-defined

[extsearch]
enabled = user-defined

[feeds]
enabled = no

[filedrop]
enabled = user-defined

[filemanager]
enabled = yes

[fileshare]
enabled = yes

[geoip]
enabled = user-defined

[history]
enabled = no

[httprpc]
canBeShutdowned = no

[instantsearch]
enabled = no

[ipad]
enabled = user-defined

[logoff]
enabled = yes

[loginmgr]
enabled = no

[mediainfo]
enabled = yes

[mediastream]
enabled = yes

[pausewebui]
enabled = yes

[ratio]
enabled = user-defined

[ratiocolor]
enabled = user-defined

[retrackers]
enabled = no

[rpc]
enabled = no

[rss]
enabled = user-defined

[rssurlrewrite]
enabled = no

[rutracker_check]
enabled = no

[scheduler]
enabled = user-defined

[screenshots]
enabled = yes

[seedingtime]
enabled = yes

[show_peers_like_wtorrent]
enabled = user-defined

[source]
enabled = yes

[theme]
enabled = yes

[throttle]
enabled = user-defined

[titlebar]
enabled = user-defined

[tracklabels]
enabled = user-defined

[trafic]
enabled = user-defined

[unpack]
enabled = user-defined
  1. 打开http://<server_ip>/rutorrent检查是否正确加载,并尝试添加种子看是否能启动下载~至此rTorrent+ruTorrent配置完成。该段的后面我将说明Autodl-irssi的安装过程

安装Autodl-irssi

"[Autodl-irssi is a] plugin for Irssi which monitors torrent IRC announce channels, downloads torrent files based on a user-defined filter, and then sends the torrent files to a local or remote torrent client."

  1. 下载源码包
mkdir -p ~/.irssi/scripts/autorun
cd ~/.irssi/scripts
curl -sL http://git.io/vlcND | grep -Po '(?<="browser_download_url": ")(.*-v[\d.]+.zip)' | xargs wget --quiet -O autodl-irssi.zip
unzip -o autodl-irssi.zip
rm autodl-irssi.zip
cp autodl-irssi.pl autorun/
mkdir -p ~/.autodl
touch ~/.autodl/autodl.cfg
  1. 更新rutorrent插件
cd /var/www/html/rutorrent/plugins
sudo rm -rf autodl-irssi
sudo git clone https://github.com/autodl-community/autodl-rutorrent.git autodl-irssi
sudo cp autodl-irssi/_conf.php autodl-irssi/conf.php
sudo chown -R www-data:www-data autodl-irssi
  1. 配置

    1. 修改监听端口并配置随机密码 sudo vi autodl-irssi/conf.php
    $autodlPort = 45638;  // Any port between 20000-65535 that you have not used previously
    $autodlPassword = "ANsbpspwy7Din97q";  // A random password. It will never be used again
    1. 修改auodl-irssi设置 vi ~/.autodl/autodl.cfg,复制以下内容,其中端口号和密码应与上步配置中相同。
    [options]
    gui-server-port = 45638
    gui-server-password = ANsbpspwy7Din97q
  2. 启动 screen -S autodl -fa -d -m irssi,并打开ruTorrent页面检查是否正确安装。没有问题的话,可以直接输入 /exit退出irssi页面,后输入exit退出screen页面
  3. 配置自启动

偷懒使用rtinst脚本工具来完成rtorrent和irssi的自启

cd /usr/local/bin
sudo wget https://github.com/arakasi72/rtinst/raw/master/scripts/rtcheck
sudo chmod +x rtcheck

然后编辑crontab文件crontab -e,添加以下两条即可

@reboot sleep 10; /usr/local/bin/rtcheck irssi rtorrent
*/10 * * * * /usr/local/bin/rtcheck irssi rtorrent

安装Transmission

包管理安装Transmission

Transmission的安装与本人已有文章Ubuntu 14.04 安装Transmission2.82的步骤基本类似,此处不再做说明。

命令大体如下:

sudo add-apt-repository ppa:transmissionbt/ppa
sudo apt-get update
sudo apt-get install transmission-cli transmission-common transmission-daemon
mkdir -p ~/transmission/{completed,incomplete,watch}
sudo usermod -a -G debian-transmission <username>
sudo chgrp -R debian-transmission ~/transmission
sudo chmod -R 775 ~/transmission

然后编辑相关配置文件并使用ronggang/transmission-web-control替换默认的web控制端。
全部完成后,你可以临时访问"http://<server_ip>:9091"检查~

扩展:编译替换支持skip hash check的transmission 2.92

这里使用的是Evalyn修改的源码包,与 superlukia/transmission-2.92_skiphashcheck 相比,基于官方Release Source修改,添加任务后选择“Ask for more peers” 或者 “Move to Queen bottom” 均可立即跳过校验。原版WebRPC或者个性化增强的WebRPC均可使用

curl https://npupt.com/downloads/transmission-2.92-skiphash-with-newui.tar.gz | tar xz
cd transmission-2.92-skiphash-with-newui
./configure
make
cd daemon
cp /usr/bin/transmission-daemon /usr/bin/transmission-daemon.old
cp transmission-daemon /usr/bin/

安装Deluge

使用包管理器安装Deluge

sudo add-apt-repository ppa:deluge-team/ppa
sudo apt-get update
sudo apt-get install deluge-webui deluged
sudo adduser --system --gecos "Deluge Service" --disabled-password --group --home /var/lib/deluge deluge
sudo gpasswd -a <username> deluge

配置Deluge

sudo vi /etc/systemd/system/deluged.service复制并粘贴以下内容

[Unit]
Description=Deluge Bittorrent Client Daemon
After=network-online.target

[Service]
Type=simple
User=deluge
Group=deluge
UMask=007

ExecStart=/usr/bin/deluged -d

Restart=on-failure

# Configures the time to wait before service is stopped forcefully.
TimeoutStopSec=300

[Install]
WantedBy=multi-user.target

并使用以下命令管理

启动:sudo systemctl start deluged
开机自启(设置一次即可):sudo systemctl enable deluged
状态检查:sudo systemctl status deluged

配置Deluge WebUI

sudo vi /etc/systemd/system/deluge-web.service复制并粘贴以下内容

[Unit]
Description=Deluge Bittorrent Client Web Interface
After=network-online.target

[Service]
Type=simple

User=deluge
Group=deluge
UMask=027

ExecStart=/usr/bin/deluge-web

Restart=on-failure

[Install]
WantedBy=multi-user.target

同样的管理命令

启动:sudo systemctl start deluge-web
开机自启(设置一次即可):sudo systemctl enable deluge-web
状态检查:systemctl status deluge-web

全部完成后,你可以临时访问"http://<server_ip>:8112"检查,默认密码为deluge

安装ItConfig

ltConfig is a plugin for Deluge that allows direct modification to libtorrent settings.

介绍页面:http://forum.deluge-torrent.org/viewtopic.php?t=42887

https://github.com/ratanakvlun/deluge-ltconfig/releases 上下载最新的egg发布文件
download_itconfig.jpg
进入Deluge WebUI配置页面安装
install_itconfig.jpg
安装完成后启用该插件即可~

安装qBtorrent

仍然是直接的包管理安装
注意,如果你需要最新版本的qb4.x,请添加官方源先sudo add-apt-repository ppa:qbittorrent-team/qbittorrent-stable

不然,请直接使用以下命令安装qb3.1左右的版本

sudo apt update && sudo apt install qbittorrent-nox

配置自启动脚本sudo vi /etc/systemd/system/qbittorrent-nox.service

[Unit]
Description=qBittorrent Daemon Service
After=network.target

[Service]
Type=forking
User=<username>
ExecStart=/usr/bin/qbittorrent-nox -d

[Install]
WantedBy=multi-user.target

并同样使用以下命令管理

启动:sudo systemctl start qbittorrent-nox
开机自启(设置一次即可):sudo systemctl enable qbittorrent-nox
状态检查:systemctl status qbittorrent-nox

完成后使用http://<server_ip>:8080访问,默认的账号和密码为adminadminadmin

安装webmin

cd /tmp
wget http://prdownloads.sourceforge.net/webadmin/webmin_1.820_all.deb
sudo dpkg --install webmin_1.820_all.deb

安装完直接访问https://<server_ip>:10000即可

配置Nginx

以下是R酱的魔法时间23333~

强制使用https访问

80端口监听的http服务使用301跳转到http,实现代码如下

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    #server_name seedbox;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    #server_name seedbox;
    root /var/www/html;
    index index.html index.php index.htm;

    client_max_body_size 40m;

    include snippets/snakeoil.conf;
        
    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ =404;
    }
}

Transmission反代

rhilip@Lolicon:/etc/nginx$ cat snippets/transmission.conf 
location /tr {
    return 301 https://$host/transmission;
}

location /transmission {
    proxy_read_timeout 300;
    proxy_pass_header  X-Transmission-Session-Id;
    proxy_set_header   X-Forwarded-Host   $host;
    proxy_set_header   X-Forwarded-Server $host;
    proxy_set_header   X-Forwarded-For    $proxy_add_x_forwarded_for;
    proxy_pass         http://127.0.0.1:9091/transmission;
}

location /rpc {
    proxy_pass         http://127.0.0.1:9091/transmission/rpc;
}

location /upload {
    proxy_pass         http://127.0.0.1:9091/transmission/upload;
}

RuTorrent 添加访问密码

rhilip@Lolicon:/etc/nginx$ cat snippets/rutorrent.conf 
location /rt {
    return 301 https://$host/rutorrent;
}

location /rutorrent {
    client_max_body_size 40m;
    auth_basic "Restricted";
    auth_basic_user_file /etc/nginx/.htpasswd;
    include /etc/nginx/conf.d/cache;
}
rhilip@Lolicon:/etc/nginx$ cat /etc/nginx/conf.d/cache
location ~* \.(jpg|jpeg|gif|css|png|js|woff|ttf|svg|eot)$ {
    expires 30d;
}

Deluge反代

rhilip@Lolicon:/etc/nginx$ cat snippets/deluge.conf 
location /de {
    return 301 https://$host/deluge;
}
location /deluge {
    proxy_pass http://127.0.0.1:8112/;
    proxy_set_header X-Deluge-Base "/deluge/";
    include /etc/nginx/conf.d/proxy;
    add_header X-Frame-Options SAMEORIGIN;
}
rhilip@Lolicon:/etc/nginx$ cat conf.d/proxy 
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_cache off;
proxy_buffering off;

qBittorrent反代

rhilip@Lolicon:/etc/nginx$ cat snippets/qbitorrent.conf 
location /qb {
    return 301 https://$host/qbitorrent/;
}
location ~ /qbitorrent/(?<url>.*) {
    proxy_pass http://127.0.0.1:8080/$url;
    proxy_set_header   X-Forwarded-Host  $host:$server_port;
    proxy_hide_header  Referer;
    proxy_hide_header  Origin;
    proxy_set_header   Referer           '';
    proxy_set_header   Origin            '';
    add_header X-Frame-Options "SAMEORIGIN";
}

重新修改默认default文件

rhilip@Lolicon:/etc/nginx$ cat sites-enabled/default
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    #server_name seedbox;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl default_server;
    listen [::]:443 ssl default_server;
    #server_name seedbox;
    root /var/www/html;
    index index.html index.php index.htm;

    client_max_body_size 40m;

    # SSL configuration
    include snippets/snakeoil.conf;

    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ =404;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;

    #    # With php7.0-cgi alone:
    #    fastcgi_pass 127.0.0.1:9000;
    #    # With php7.0-fpm:
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }
    
    include snippets/transmission.conf;
    include snippets/rutorrent.conf;
    include snippets/deluge.conf;
    include snippets/qbitorrent.conf;
    #include snippets/download.conf;
    
    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    location ~ /\.ht {
        deny all;
    }
}

全部引用源

在全部的过程中参考了很多的文章,在此表示感谢。

标签: seedbox

非特殊说明,本博所有文章均为博主原创。

评论啦~



已有 3 条评论


  1. rapahel
    rapahel

    没有系统的一些网络优化设置吗?

    回复 2018-04-13 20:19
    1. Rhilip
      Rhilip 博主

      因为这只是100M管杜甫,所以只上了个BBR就差不多了。
      另外请确认你的Seedbox瓶颈是不是在网络上,而不是在硬盘io、cpu、内存上。

      回复 2018-04-14 10:17
  2. Roccoon
    Roccoon

    Deluge有没有不修改源码支持跳过文件校验的方法啊?

    回复 2018-06-12 23:57