温馨提示:本文最后更新于2023年9月24日,已超过 30 天没有更新,某些文章具有时效性,若有错误或已失效,请在下方留言!

写在前面

本网站开通了网盘服务,方便大文件下载和分享。点此访问

如果直接在服务器上本地访问,使用 [IP地址]:[端口号] 即可访问。为了能够在外网访问,在Nginx里设置反向代理,使用域名访问。

之前的云盘链接是 https://pan.hb2cpc.top/ ,但后来随着在线工具越来越多,需要反向代理的服务越来越多,如果给每一个服务都分配一个独立的二级域名,不仅操作不方便,而且难以管理,很容易就达到Sakura内网穿透的限制(10条隧道)。所以考虑使用统一的域名tool.hb2cpc.top管理,使用子目录进行区分。

操作步骤

假设我现在想使用https://tool.hb2cpc.top/pan访问网盘服务。

1. 修改config.json文件,其所在位置根据实际情况而定。

  • Windows/Mac:和 AList 同级文件夹内的 data/config.json
  • Linux:一键脚本路径:/opt/alist/data/config.json,手动安装:/xx 路径/data/config.json
  • Docker:进入 Docker 容器内 data/config.json
  • openwrt:如果使用的是 luci-app-alist,请在网页修改,其他自行找到 AList 执行文件同级目录data/config.json
  • 其他:找到 AList 同级文件夹內的 data/config.json

这里我是使用一键安装脚本,所以使用如下命令修改:

sudo nano /opt/alist/data/config.json

2. 修改"site_url"为"/pan"

3. 退出nano,重启AList

sudo systemctl restart alist

4. 编辑Nginx配置文件,添加如下所示代码:

location /pan/ {
      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:5244/pan/;
      # the max size of file to upload
      client_max_body_size 20000m;
}

如果使用宝塔面板,还需要注释以下内容:

#禁止访问的文件或目录
location ~ ^/(\.user.ini|\.htaccess|\.git|\.env|\.svn|\.project|LICENSE|README.md)
{
    return 404;
}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
    expires      30d;
    error_log /dev/null;
    access_log /dev/null;
}

location ~ .*\.(js|css)?$
{
    expires      12h;
    error_log /dev/null;
    access_log /dev/null;
}

5. 重启Nginx即可

sudo systemctl restart nginx
最后更新于 2023-09-24