torrust是一个开源项目,你可以使用它来建立一个自己的pt网站。
torrust主要分为两个部分:torrust-tracker和torrust-index。torrust-tracker是一个bt跟踪器,而torrust-index是一个web前端。
先来安装torrust-tracker。安装所需的包:
apt -y update apt -y install curl git build-essential nginx python3-certbot-nginx pkg-config libssl-dev libsqlite3-dev
安装rust:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh source "$HOME/.cargo/env"
新建目录:
mkdir /opt/torrust && cd /opt/torrust
克隆项目存储库:
git clone -b v3.0.0-alpha.1 https://github.com/torrust/torrust-tracker.git cd torrust-tracker
编译:
cargo build --release
先运行一次,让其生成配置文件:
./target/release/torrust-tracker
编辑配置文件:
nano config.toml
我的配置,必须要改动的位置写了注释:
log_level = "info" mode = "private" // 私有模式 db_driver = "Sqlite3" db_path = "data.db" // 数据库存储路径 announce_interval = 120 min_announce_interval = 120 on_reverse_proxy = true // 启用反向代理 external_ip = "0.0.0.0" tracker_usage_statistics = true persistent_torrent_completed_stat = false max_peer_timeout = 900 inactive_peer_cleanup_interval = 600 remove_peerless_torrents = true [[udp_trackers]] enabled = false bind_address = "0.0.0.0:6969" [[http_trackers]] enabled = true // 启用http tracker bind_address = "127.0.0.1:6969" // 仅监听本地的6969端口 ssl_enabled = false ssl_cert_path = "" ssl_key_path = "" [http_api] enabled = true // 启用api bind_address = "127.0.0.1:1212" // 仅监听本地的1212端口 ssl_enabled = false ssl_cert_path = "" ssl_key_path = "" [http_api.access_tokens] admin = "apipassword" // api访问密码
新建systemd服务:
systemctl edit --full --force torrust-tracker.service
写入如下配置:
[Unit] Description=torrust-tracker service Documentation=https://torrust.com/ After=network.target [Service] WorkingDirectory=/opt/torrust/torrust-tracker ExecStart=/opt/torrust/torrust-tracker/target/release/torrust-tracker Restart=on-failure LimitNOFILE=infinity [Install] WantedBy=multi-user.target
启动并设置开机自启:
systemctl enable --now torrust-tracker.service
新建nginx站点配置文件:
nano /etc/nginx/sites-available/torrust-tracker
写入如下配置,把域名tracker.example.com换成你自己的:
server { listen 80; server_name tracker.example.com; location / { proxy_set_header X-Forwarded-For $remote_addr; proxy_pass http://127.0.0.1:6969; } }
启用新的配置:
ln -s /etc/nginx/sites-available/torrust-tracker /etc/nginx/sites-enabled/torrust-tracker
签发ssl证书:
certbot --nginx
你的跟踪器地址将是:https://tracker.example.com/announce
接下来安装torrust-index。torrust-index实际上还可以细分为一个前端和后端,先来安装后端。
安装nodejs:
curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && apt -y install nodejs
进入到torrust目录,克隆torrust-index-backend项目代码:
cd /opt/torrust git clone -b v2.0.0-dev.1 https://github.com/torrust/torrust-index-backend.git cd torrust-index-backend/
创建env文件:
echo "DATABASE_URL=sqlite://data.db?mode=rwc" > .env
安装sqlx-cli:
cargo install sqlx-cli
初始化数据库:
sqlx db setup
编译:
cargo build --release
先运行一次,让其生成配置文件:
./target/release/torrust-index-backend
编辑配置文件:
nano config.toml
我的配置,必须要改动的位置写了注释::
[website] name = "Torrust" [tracker] url = "https://tracker.example.com/announce" // torrust-tracker的tracker地址 mode = "Private" // 私有模式 api_url = "http://127.0.0.1:1212" // torrust-tracker的api地址 token = "apipassword" // torrust-tracker的api访问密码 token_valid_seconds = 7257600 [net] port = 3000 [auth] email_on_signup = "Optional" min_password_length = 6 max_password_length = 64 secret_key = "password" // 随便输一个字符串 [database] db_driver = "Sqlite3" connect_url = "sqlite://data.db?mode=rwc" torrent_info_update_interval = 3600 [mail] email_verification_enabled = false
新建systemd服务:
systemctl edit --full --force torrust-backend.service
写入如下配置:
[Unit] Description=torrust-tracker service Documentation=https://torrust.com/ After=network.target [Service] WorkingDirectory=/opt/torrust/torrust-index-backend ExecStart=/opt/torrust/torrust-index-backend/target/release/torrust-index-backend Restart=on-failure LimitNOFILE=infinity [Install] WantedBy=multi-user.target
启动并设置开机自启:
systemctl enable --now torrust-backend.service
接下来安装torrust-index的前端。
克隆项目代码:
cd /opt/torrust git clone -b v2.0.0 https://github.com/torrust/torrust-index-frontend.git cd torrust-index-frontend/
创建env文件,把域名pt.example.com换成你自己的:
echo "VITE_API_BASE_URL=https://pt.example.com/api" > .env
构建前端,完成后在dist目录下就是前端的文件:
npm i
npm run build
新建nginx站点配置文件:
nano /etc/nginx/sites-available/torrust-index
写入如下配置:
server { listen 80; server_name pt.example.com; root /opt/torrust/torrust-index-frontend/dist/; location / { try_files $uri $uri/ /index.html; } location /api/ { proxy_pass http://127.0.0.1:3000/; } }
启用新的nginx配置:
ln -s /etc/nginx/sites-available/torrust-index /etc/nginx/sites-enabled/torrust-index
签发ssl证书:
certbot --nginx
打开站点,第一个注册的账号自动成为管理员:
试了下基本的功能都有,就是前端不太好看,比较简陋:
参考:
https://github.com/torrust/torrust-tracker
https://github.com/torrust/torrust-index-backend
https://github.com/torrust/torrust-index-frontend
https://torrust.com/
暂无评论内容