跳至主要內容

折腾杂谈:部署Alist并整合/服务器优化

Menghuan1918大约 2 分钟

本文内容:

  • 部署Alist网盘服务到二级网址
  • 优化网站生成流程
  • 使用tailscale加快SSH速度

部署Alist

不出意外地是用Docker部署(貌似也不准确,因为实际上是docker compose部署),按照其手册open in new window设置docker-compose.yml:

version: '3.3'
services:
    alist:
        image: 'xhofe/alist:latest'
        container_name: alist
        volumes:
            - '/etc/alist:/opt/alist/data'
        ports:
            - '5244:5244'
        environment:
            - PUID=0
            - PGID=0
            - UMASK=022
        restart: unless-stopped

随后docker-compose up -d运行,这时候访问服务器ip:5244(记得设置防火墙)就能查看到登录界面了。随后进行密码的设置:

docker exec -it alist ./alist admin set PASSWORD

随后就能进入Alist网页,在下方点击管理按钮进行响应的设置了。

设置Nginx转发为二级网址

为了将Alist部署到二级页面(也就是/AlistStore 上open in new window),还需要手动设置site_url的值。

根据手册open in new window可以看到配置文件目录为Docker:进入 Docker 容器内data/config.json,考虑到前文的docker-compose.yml中,volumes的设置是- '/etc/alist:/opt/alist/data',也就是说这个配置文件也可以在实体机上的/etc/alist/config.json中找到。

修改其site_url"https://blog.menghuan1918.com/AlistStore",随后重启容器。

其中Nginx需要遵从其手册open in new window添加:

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:5244/alist/;
    client_max_body_size 20000m;
}

随后访问https://blog.menghuan1918.com/AlistStore/open in new window就能看到了。

一些关于服务器的优化

优化部署流程

虽然整体而言就是 编译为静态网页 -> 压缩图片 -> 同步到服务器。将后两步操作写为一个Shell脚本open in new window,随后修改package.json

"docs:build": "vuepress-vite build src && sh ./UpWeb.sh",

这样就能一键走完这一套了~

使用tailscale加快SSH速度

由于某些因素的影响 (狗屎校园网),SSH连接服务器的速度可谓是难以忍受(试想按下回车后居然没反应,等几秒果然是网卡了)。不过使用tailscale建立虚拟局域网就没那么多事情了......按照其安装文档open in new window安装即可。

不过在阿里云上有一个暗坑,tailscale的 魔法DNS (MagicDNS) 会把阿里云的内网更新地址给挤掉。为了加快更新速度 节省服务器流量 ,最简单的方法是关掉这个功能。

tailscale down
tailscale up --accept-dns=false --netfilter-mode=off

这样就好了,将SSH的ip地址更换为tailscale中的局域网地址,明显流畅丝滑多了。