飘在云端

东西南北,海角天涯

· 未定义 · · 554次浏览

Filebrowser 最新版 v2.23.0 配置的一些坑

更新:2022-12-11
环境:
Filebrowser v2.23.0
Nginx v1.22.1
Ubuntu v22.04.1 LTS

Alist 最新版v3.6.0,大文件上传触发 OOM 文件一直没有解决,上传 1 GiB 的文件都能触发 OOM,开发者的issue也没什么办法,只能搭配 Filebrowser 结合使用了,Alist 专职提供目录列表、预览、下载,Filebrowser 提供上传

下载最新版 Linux x64 架构的 release

wget https://github.com/filebrowser/filebrowser/releases/download/v2.23.0/linux-amd64-filebrowser.tar.gz

解压:tar zxvf linux-amd64-filebrowser.tar.gz -C /root

作为服务后台启动,创建一个空白文件,touch /etc/systemd/system/filebrowser.service,内容如下

[Unit]
Description=filebrowser service
After=network.target

[Service]
Type=simple
User=root
Group=root
WorkingDirectory=/root
Restart=always
RestartSec=3
ExecStart=/root/filebrowser -d=/root/filebrowser.db --disable-type-detection-by-header -b=/ --cache-dir=/root/files/cache --img-processors 6

[Install]
WantedBy=multi-user.target

注意先自行生成配置 .db 数据库文件,配置方法说明见自带帮助 ./filbrowser --help

其中,systemctl 的配置项 ExecStart 输入 Filebrowser 路径和参数,这里 Filebrowser 执行文件参数不认 --参数名 "参数值" 的形式,要改成 --(或-)参数名 = 参数值 的形式,不然会报错,详见上面示例,每个参数结尾以 空格分割,且路径必须为绝对路径。

踩了一大堆坑哇

其他要注意的:
Filebrowser中的参数 baseurl 的值为网站路径(location匹配的路径),如果是部署在根目录,则为 /,如部署在二级目录, https://www.example.com/test,则为 /test

重新加载服务列表 systemctl daemon-reload
配置自启动 systemctl enable filebrowser

启动 Filebrowser systemctl start filebrowser
重启 Filebrowser systemctl restart filebrowser
停止 Filebrowser systemctl stop filebrowser
查看运行日志 systemctl status -l filebrowser

更多参数详见命令行帮助 ./filebrowser help config set

Nginx 反代配置优化,只列出关键部分:
注意我这里是 root 权限运行的 nginx,请根据实际情况修改。

server

server {
#其他内容
#允许大文件上传
client_max_body_size 0;
}

location

location ~* / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
#大文件上传参数优化
proxy_read_timeout                      86400s;
proxy_send_timeout                      86400s;
proxy_redirect                          off;
proxy_set_header                        Upgrade $http_upgrade;
proxy_set_header                        Connection "upgrade";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

#禁止服务端、客户端缓存策略
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
 if_modified_since off;
 expires off;
 etag off;
}

自定义 CSS 和 Logo
在 root 目录中使用 tree -L 3,输出的路径层次为以下结构

├── filebrowser
├── filebrowser.db
├── files
│   ├── cache
├── custom.css
├── img
│   ├── icons
│   │   ├── android-chrome-192x192.png
│   │   ├── android-chrome-512x512.png
│   │   ├── apple-touch-icon.png
│   │   ├── browserconfig.xml
│   │   ├── favicon-16x16.png
│   │   ├── favicon-32x32.png
│   │   ├── favicon.ico
│   │   ├── mstile-150x150.png
│   │   ├── safari-pinned-tab.svg
│   │   └── site.webmanifest
│   └── logo.svg
├── tlscert
└── tlskey

此外如果 Nginx 配置启用了 gzip_static on,会导致 CSS、Logo 修改无法立刻生效预览,需要手动清除 Nginx 缓存

并发上传 2 个文件,1个1.7 GiB,一个 1.9 GiB,啊!这极低的内存占用和CPU开销,爱了

请输入图片描述

评论 (0条)