嘟嘟

阿里云盘目录列表程序AList部署教程

简介

作者简介:AList是一款阿里云盘的目录文件列表程序,后端基于golang最好的http框架gin,前端使用vueant design。没有专门学过前端,大佬轻喷。

本程序仅供学习研究使用!!!发现任何bug请提issue,部署上遇到问题欢迎加群交流。

更新的时候后端和前端文件都需要替换!!!!以及补上配置文件新的配置项!!!!第一次启动需要网页底部rebuild!!!

项目地址

预览

如何部署

获取refresh_token

为什么不直接使用access_token,因为有效期只有两小时。经Syc大佬的提醒,获取refresh_token其实没这么麻烦,我们只需要登陆阿里云盘之后,打开开发者工具,切换到Application选项卡,点开Local storage,会有一个token项,点开就可以看到refresh_token了,此处感谢一下Syc大佬。

部署

使用gin作为静态资源服务器

info:  title: AList #标题  logo: "" #网站logo 如果填写,则会替换掉默认的  footer_text: Xhofe's Blog #网页底部文字  footer_url: https://www.nn.ci #网页底部文字链接  music_img: https://img.xhofe.top/2020/12/19/0f8b57866bdb5.gif #预览音乐文件时的图片  check_update: true #前端是否显示更新  script: #自定义脚本,可以是脚本的链接,也可以直接是脚本内容  autoplay: true #视频是否自动播放  preview:    text: [txt,htm,html,xml,java,properties,sql,js,md,json,conf,ini,vue,php,py,bat,gitignore,yml,go,sh,c,cpp,h,hpp] #要预览的文本文件的后缀,可以自行添加server:  address: "0.0.0.0"  port: "5244"  search: true  static: dist  site_url: '*'  password: password #用于重建目录ali_drive:  api_url: https://api.aliyundrive.com/v2  max_files_count: 3000  drives:  - refresh_token: xxx #refresh_token    root_folder: root #根目录的file_id    name: drive0 #盘名,多个盘不可重复,这里只是示例,不是一定要叫这个名字,可随意修改    password: pass #该盘密码,空('')则不设密码,修改需要重建生效    hide: false #是否在主页隐藏该盘,不可全部隐藏,至少暴露一个  - refresh_token: xxx #只有一个盘的话,该段完全可以删除,反之有更多可以继续添加    root_folder: root    name: drive1    password: pass    hide: falsedatabase:  type: sqlite3  dBFile: alist.db
$ tree.├── alist├── conf.yml└── dist    ├── favicon.ico    ├── index.html    └── static        ├── css        │   ├── about.f0b54b1c.css        │   ├── app.4f0c3e9a.css        │   └── chunk-vendors.8f913079.css        ├── img        │   └── alist.bcb68ba0.png        └── js            ├── about.8108f65b.js            ├── app.34cb39e5.js            └── chunk-vendors.131f0f41.js 5 directories, 12 files
chmod +x alistnohup ./alist > log.log 2>&1 &

ok,程序已经跑起来了。你可以 cat log.log 看看有没有报错。或者访问http://ip:5244进行查看。

守护进程(可选)

vim /usr/lib/systemd/system/alist.service添加以下内容,其中path_alist为alist所在的路径

[Unit]Description=alistAfter=network.target [Service]Type=simpleWorkingDirectory=path_alistExecStart=path_alist/alist -conf conf.ymlRestart=on-failure [Install]WantedBy=multi-user.target

然后systemctl daemon-reload重载配置,现在你就可以使用这些命令来管理程序了:

使用mysql(可选)

需要使用utf8mb4编码,修改database部分配置:

database:  type: mysql  user: 用户名  password: 密码  host: 127.0.0.1  port: 3306  name: 数据库名

自定义静态资源服务器

与使用gin作为静态资源服务器操作步骤差不多,不同的地方在于:

location / {  try_files $uri $uri/ /index.html;}

参考:https://router.vuejs.org/zh/guide/essentials/history-mode.html

反向代理

程序默认监听5244端口,要实现https访问,需要使用nginx反向代理,在配置文件中加入

    location / {        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;        proxy_set_header Host $http_host;        proxy_set_header X-Real-IP $remote_addr;        proxy_redirect off;        proxy_pass http://127.0.0.1:5244;    }

常见问题解答