一、什么是 Alist?
Alist 是一个基于 Go 语言开发的轻量级网盘目录列表和文件管理系统,支持多种存储后端(本地、OneDrive、阿里云盘等),界面简洁,部署简单。
二、准备条件
- 已安装好 Docker 和 Docker Compose(可选)
- 主机有可用端口(默认 5244)
- 推荐映射数据目录持久化配置和文件
三、Docker 方式快速部署 Alist
1. 直接使用 Docker 命令启动
lua
docker run -d \
--name alist \
-p 5244:5244 \
-v /path/to/alist/data:/data \
-v /path/to/alist/config:/config \
--restart unless-stopped \
xhofe/alist
php
162 Bytes
© 菜鸟-创作你的创作
-p 5244:5244
:将容器内 5244 端口映射到宿主机 5244 端口-v /path/to/alist/data:/data
:映射文件存储目录(自己放文件的目录)-v /path/to/alist/config:/config
:映射配置目录(Alist 配置文件存放地)--restart unless-stopped
:容器自动重启策略
启动后浏览器访问 http://你的服务器IP:5244
,默认账号密码均是 admin
。
2. 使用 Docker Compose 部署示例
创建 docker-compose.yml
:
ruby
version: '3'
services:
alist:
image: xhofe/alist
container_name: alist
restart: unless-stopped
ports:
- "5244:5244"
volumes:
- /path/to/alist/data:/data
- /path/to/alist/config:/config
php
224 Bytes
© 菜鸟-创作你的创作
运行:
docker-compose up -d
php
20 Bytes
© 菜鸟-创作你的创作
四、常用操作
-
查看日志:
docker logs -f alist
php
20 Bytes
© 菜鸟-创作你的创作 -
进入容器:
bash
docker exec -it alist /bin/sh
php
29 Bytes
© 菜鸟-创作你的创作
- 停止容器:
arduino
docker stop alist
php
17 Bytes
© 菜鸟-创作你的创作
- 启动容器:
sql
docker start alist
php
18 Bytes
© 菜鸟-创作你的创作
五、配置持久化和备份
/path/to/alist/config
目录保存 Alist 的所有配置文件,备份此目录即可备份配置。/path/to/alist/data
是你共享的文件存储目录。
六、其他参考
- 官方镜像地址:hub.docker.com/r/xhofe/ali...
- Alist 项目主页:alist.nn.ci/
- 官方文档详细说明功能和配置项。
明白!下面帮你写一个基于 Nginx 反向代理 + HTTPS 的完整示例,配合 Docker 部署的 Alist 做安全访问。
一、准备条件
- 你的服务器能访问外网,已安装 Docker 和 Docker Compose。
- 域名已解析到服务器公网 IP。
- 安装了 Nginx(可用宿主机或 Docker 内 Nginx)。
- 获取 SSL 证书(推荐使用 Let's Encrypt 免费证书)。
二、示例结构说明
bash
/alist/
├── docker-compose.yml
└── nginx/
├── alist.conf
├── ssl/
├── fullchain.pem
└── privkey.pem
php
123 Bytes
© 菜鸟-创作你的创作
三、步骤详解
1. Docker Compose 配置(alist/docker-compose.yml)
yaml
version: '3'
services:
alist:
image: xhofe/alist
container_name: alist
restart: unless-stopped
ports:
- "5244:5244" # 暴露容器端口,不直接外网访问
volumes:
- ./data:/data
- ./config:/config
php
224 Bytes
© 菜鸟-创作你的创作
2. Nginx 配置(alist/nginx/alist.conf)
ini
server {
listen 80;
server_name your.domain.com;
# 强制重定向到 HTTPS
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name your.domain.com;
ssl_certificate /etc/nginx/ssl/fullchain.pem;
ssl_certificate_key /etc/nginx/ssl/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
location / {
proxy_pass http://localhost:5244/; # 反向代理到 Alist 容器映射端口
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# WebSocket 支持(如果需要)
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
php
813 Bytes
© 菜鸟-创作你的创作
注意:将
your.domain.com
替换成你的真实域名。
3. 将 SSL 证书放到 nginx/ssl 目录
- 使用 Let's Encrypt 获取证书后,将
fullchain.pem
和privkey.pem
放入该目录。
4. 启动服务
bash
cd /alist
docker-compose up -d
php
30 Bytes
© 菜鸟-创作你的创作
启动 Nginx(假设是宿主机 Nginx,执行 nginx -s reload
使配置生效)
5. 访问测试
打开浏览器访问:
arduino
https://your.domain.com
php
23 Bytes
© 菜鸟-创作你的创作
应该可以看到 Alist 的登录页面。
四、补充建议
- 安全:登录后及时修改默认密码。
- 防火墙:只开放 80/443 端口,关闭 5244 端口外网访问。
- 自动续期:使用 certbot 配合定时任务自动续期 Let's Encrypt 证书。
明白!这里帮你写一个 Docker Compose 一体化部署 Alist + Nginx + Certbot 自动续期 HTTPS 的完整示例,适合快速启动并自动维护证书。
一、目录结构示范
bash
alist-docker/
├── docker-compose.yml
├── nginx/
│ ├── conf.d/
│ │ └── alist.conf
│ └── certs/ # 证书文件会自动挂载到这里
└── data/ # Alist 数据目录
└── config/ # Alist 配置目录
php
199 Bytes
© 菜鸟-创作你的创作
二、docker-compose.yml 内容
yaml
version: '3.8'
services:
alist:
image: xhofe/alist
container_name: alist
restart: unless-stopped
volumes:
- ./data:/data
- ./config:/config
expose:
- "5244" # 只暴露给内网,不映射到宿主机
networks:
- alist-net
nginx:
image: nginx:stable-alpine
container_name: alist-nginx
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx/conf.d:/etc/nginx/conf.d
- ./nginx/certs:/etc/nginx/certs:ro
depends_on:
- alist
networks:
- alist-net
certbot:
image: certbot/certbot
container_name: certbot
volumes:
- ./nginx/certs:/etc/letsencrypt
- ./nginx/conf.d:/etc/nginx/conf.d
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew --webroot -w /var/www/certbot --quiet; sleep 12h & wait $${!}; done;'"
networks:
- alist-net
networks:
alist-net:
driver: bridge
php
930 Bytes
© 菜鸟-创作你的创作
三、Nginx 配置(nginx/conf.d/alist.conf)
ini
server {
listen 80;
server_name your.domain.com;
location /.well-known/acme-challenge/ {
root /var/www/certbot;
}
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl http2;
server_name your.domain.com;
ssl_certificate /etc/nginx/certs/live/your.domain.com/fullchain.pem;
ssl_certificate_key /etc/nginx/certs/live/your.domain.com/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
location / {
proxy_pass http://alist:5244/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
php
898 Bytes
© 菜鸟-创作你的创作
记得替换
your.domain.com
为你的真实域名。
四、初次申请证书命令示范
第一次运行前,需要先手动申请证书,示例:
bash
docker run --rm -it \
-v $(pwd)/nginx/certs:/etc/letsencrypt \
-v $(pwd)/nginx/conf.d:/etc/nginx/conf.d \
certbot/certbot certonly --webroot \
--webroot-path=/var/www/certbot \
--email your-email@example.com \
--agree-tos --no-eff-email \
-d your.domain.com
php
271 Bytes
© 菜鸟-创作你的创作
五、启动步骤
-
修改
alist.conf
中的域名。 -
手动申请证书(步骤四)。
-
启动服务:
docker-compose up -d
php
20 Bytes
© 菜鸟-创作你的创作 -
访问
https://your.domain.com
验证。
六、自动续期说明
certbot
容器会每12小时执行一次证书续期,自动更新。- Nginx 证书目录绑定共享,更新后无需手动重启容器。