安装和基本介绍
About 2 min
基本介绍
这是 B 站弹幕解析服务器。
安装
Warning
后面的教程戾气较重,心理承受能力差的别看,别对号入座。
Note
不支持 CentOS6,不支持 CentOS6,不支持 CentOS6,用 CentOS6 的自己想办法解决,仅在 Debian/Ubuntu 系系统测试,其他系统不能保证兼容性。
流程
- 下载预编译文件到服务器
- 编辑配置文件
appsettings.json
- 配置进程守护
- 配置反向代理
- 测试
下载
授予运行权限
sudo chmod +x Danmu.Bili
配置
编辑 appsettings.json
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"Kestrel": {
"Endpoints": {
"Http": {
"Url": "http://localhost:5000",
"Protocols": "Http1AndHttp2AndHttp3"
}
}
},
"AllowedHosts": "*",
"WithOrigins": ["*"],
"BiliBiliSetting": {
"PageCacheTime": 8640,
"DanMuCacheTime": 6
},
"DataBase": {
"Directory": "DataBase",
"DanMuCachingDb": "DanMuCaching.db"
},
"UnixSocket": ""
}
需要修改的部分
Kestrel.Endpoints.Http.Url
修改为不冲突的端口AllowedHosts
添加自己的域名,多个域名使用;
隔开,如"danmu.u2sb.com;localhost"
,也可以直接填写"*"
WithOrigins
允许跨域请求的域名,默认不需要修改UnixSocket
UnixSocket 路径
配置进程守护
以 systemd
为例
[Unit]
Description=danmu-bili
[Service]
User=mc
WorkingDirectory=/home/mc/www/danmu.bili/
ExecStart=/home/mc/www/danmu.bili/Danmu.Bili
Restart=always
RestartSec=5s
[Install]
WantedBy=multi-user.target
配置反向代理
以 nginx 为例
server {
listen 443 http3;
listen 443 http2;
server_name danmu-bili.s2.u2sb.com;
ssl_early_data on;
proxy_set_header Early-Data $ssl_early_data;
ssl_protocols TLSv1.2 TLSv1.3;
add_header Alt-Svc 'h3=":443"; ma=86400, h3-29=":443"; h3-28=":443";';
ssl_certificate /home/mc/.acme.sh/*.s2.u2sb.com_ecc/fullchain.cer;
ssl_certificate_key /home/mc/.acme.sh/*.s2.u2sb.com_ecc/*.s2.u2sb.com.key;
index index.html index.htm;
location /js/ {
root /home/mc/www/danmu.bili/wwwroot/;
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
if ($request_method = 'OPTIONS') {
return 204;
}
}
location /api/ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass "http://unix:/home/mc/www/danmu.bili/danmu.sock";
zstd_types text/html text/plain application/xml application/json application/octet-stream;
brotli_types text/html text/plain application/xml application/json application/octet-stream;
gzip_types text/html text/plain application/xml application/json application/octet-stream;
}
}
感谢
本项目开发过程中参考了以下项目,在此表示感谢: