关于使用路径目录反向代理 AList
约 243 字小于 1 分钟
2024-11-03
配置
- 有公网的服务器
- 使用 nginx 反向代理
- docker 部署 AList
虽然有 官方文档,但还是踩了很多坑
首先要进入 docker 容器的终端,在 data/config.json 中将site_url 的值改为 '/alist',保存退出
接下来需要修改 nginx 进行反向代理,以宝塔面板为例,假设我使用域名 exmple.com 用于反向代理,当你创建该域名的反代项目后一般在 /www/server/panel/vhost/nginx
下会出现一个 exmple.com.conf 配置文件,添加以下内容
location /alist/ {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Range $http_range;
proxy_set_header If-Range $http_if_range;
proxy_redirect off;
proxy_pass http://127.0.0.1:15244/alist/;
# the max size of file to upload
client_max_body_size 20000m;
}
注意:location后的 'alist' 需要被两个 '/'包围,proxy_pass 字段中的结尾也需要 '/alist/',若依旧访问不正常,可以尝试在location 和 /alist/ 间加上 '^~'
location ^~ /alist/ {
...
}