-
Notifications
You must be signed in to change notification settings - Fork 2
self hosting
炳 edited this page Sep 16, 2024
·
15 revisions
- clone 本 git 仓库,进入 git 仓库目录。
- 确认系统安装有 Python 库
Requests
,Debian 系其实会自带。 - 运行
init_deb.py
初始化。
默认只新建 x86_64 表,需要其他架构请修改其中的SQL语句。
- 将
update_gen.sh
中 gpg 开头的两行注释。 - 创建定时任务,定时运行
update_gen.sh
crontab 样例:0 11,15,19 * * * cd [THIS_DIR] && ./update_gen.sh >> ./deb/status.txt
请根据实际情况进行修改。
echo "deb [allow-insecure=yes] file:/path/to/debs ./" | sudo tee /etc/apt/sources.list.d/wcbing.list
- 创建一个无密码的 GPG 密钥对,导出 GPG 公钥文件待用。
- 创建定时任务,定时运行
update_gen.sh
crontab 样例:0 11,15,19 * * * cd [THIS_DIR] && ./update_gen.sh >> ./deb/status.txt
这个仓库使用了扁平仓库格式(Flat Repository Format)。建立好后使用 Web 服务器将 deb
目录暴露出去即可。
实际使用中官网提供的下载链接一般是 CDN 链接,为提升下载速度、减轻自建源压力,建议将这些请求重定向到官网上。 而国内下载 Github 上的文件时比较慢,仍然从自建源下载。部分国内软件下载链接有验证,单纯反代不可以,也仍然从自建源下载。
给出两个参考配置。
nginx 做文件服务器
- nginx 配置参考:
server {
server_name packages.wcbing.top;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
charset 'utf-8';
location ~ /.*/https:/github\.com {
root /packages;
}
location ~ /.*/https:/(.+/.*) {
return 302 https://$1;
}
location / {
root /packages;
}
}
dufs + nginx 反代
- 运行 dufs,可自行注册为服务:
dufs -p 5001 --render-try-index /packages
- nginx 反代配置参考:
server {
server_name packages.wcbing.top;
location ~ /(.*/https:/github\.com.*) {
proxy_pass http://127.0.0.1:5001/$1;
}
location ~ /.*/https:/(.+/.*) {
return 302 https://$1;
}
location / {
proxy_pass http://127.0.0.1:5001;
}
}
用户使用时通过下面的命令导入配置,先将上一步提到生成的 GPG 公钥导入,再新建软件源配置文件。
请根据实际情况进行修改。
sudo curl -o /etc/apt/keyrings/wcbing.gpg https://packages.wcbing.top/wcbing.gpg
echo "deb [signed-by=/etc/apt/keyrings/wcbing.gpg] https://packages.wcbing.top/deb /" | sudo tee /etc/apt/sources.list.d/wcbing.list