Initial commit - 玩玩云文件管理系统 v1.0.0
- 完整的前后端代码 - 支持本地存储和SFTP存储 - 文件分享功能 - 上传工具源代码 - 完整的部署文档 - Nginx配置模板 技术栈: - 后端: Node.js + Express + SQLite - 前端: Vue.js 3 + Axios - 存储: 本地存储 / SFTP远程存储
This commit is contained in:
189
DEPLOYMENT.md
Normal file
189
DEPLOYMENT.md
Normal file
@@ -0,0 +1,189 @@
|
||||
# 玩玩云部署指南
|
||||
|
||||
## 快速部署
|
||||
|
||||
### 1. 基础部署(Docker Compose)
|
||||
|
||||
```bash
|
||||
# 克隆项目
|
||||
git clone <repository-url>
|
||||
cd ftp-web-manager
|
||||
|
||||
# 启动服务
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
服务将在以下端口运行:
|
||||
- Frontend (Nginx): 8080 (HTTP), 8443 (HTTPS)
|
||||
- Backend (Node.js): 40001
|
||||
|
||||
### 2. 如果使用宿主机Nginx作为反向代理
|
||||
|
||||
如果你在宿主机上使用Nginx作为SSL终止/反向代理(推荐用于生产环境),需要在Nginx配置中添加大文件上传支持。
|
||||
|
||||
#### 2.1 创建Nginx配置文件
|
||||
|
||||
创建 `/etc/nginx/sites-available/wanwanyun.conf`(或对应的配置目录):
|
||||
|
||||
```nginx
|
||||
server {
|
||||
listen 80;
|
||||
server_name your-domain.com;
|
||||
|
||||
# HTTP重定向到HTTPS
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
server_name your-domain.com;
|
||||
|
||||
# SSL证书配置(使用Let's Encrypt或其他证书)
|
||||
ssl_certificate /path/to/fullchain.pem;
|
||||
ssl_certificate_key /path/to/privkey.pem;
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers HIGH:!aNULL:!MD5;
|
||||
ssl_prefer_server_ciphers on;
|
||||
|
||||
# 反向代理到Docker容器
|
||||
location / {
|
||||
# ⚠️ 重要:设置最大上传文件大小为5GB
|
||||
client_max_body_size 5G;
|
||||
|
||||
# ⚠️ 重要:大文件上传超时设置(1小时)
|
||||
proxy_read_timeout 3600s;
|
||||
proxy_send_timeout 3600s;
|
||||
proxy_connect_timeout 3600s;
|
||||
|
||||
# 代理到Docker容器的8080端口
|
||||
proxy_pass http://127.0.0.1:8080;
|
||||
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";
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### 2.2 应用配置
|
||||
|
||||
```bash
|
||||
# 启用站点配置
|
||||
ln -s /etc/nginx/sites-available/wanwanyun.conf /etc/nginx/sites-enabled/
|
||||
|
||||
# 测试Nginx配置
|
||||
nginx -t
|
||||
|
||||
# 重新加载Nginx
|
||||
nginx -s reload
|
||||
```
|
||||
|
||||
### 3. 宝塔面板用户
|
||||
|
||||
如果使用宝塔面板,配置文件通常在:
|
||||
- `/www/server/panel/vhost/nginx/your-domain.conf`
|
||||
|
||||
在站点的 `location /` 块中添加:
|
||||
|
||||
```nginx
|
||||
location / {
|
||||
# 设置最大上传文件大小为5GB
|
||||
client_max_body_size 5G;
|
||||
|
||||
# 大文件上传超时设置(1小时)
|
||||
proxy_read_timeout 3600s;
|
||||
proxy_send_timeout 3600s;
|
||||
proxy_connect_timeout 3600s;
|
||||
|
||||
# ... 其他代理配置
|
||||
}
|
||||
```
|
||||
|
||||
然后重载Nginx:
|
||||
```bash
|
||||
nginx -s reload
|
||||
```
|
||||
|
||||
## 上传限制说明
|
||||
|
||||
系统支持的最大上传文件大小为 **5GB**,需要在以下三个层级进行配置:
|
||||
|
||||
### 1. ✅ 容器内Nginx(已配置)
|
||||
- 文件:`nginx/nginx.conf`
|
||||
- 配置:`client_max_body_size 5G;`
|
||||
|
||||
### 2. ✅ 后端Multer(已配置)
|
||||
- 文件:`backend/server.js`
|
||||
- 配置:`limits: { fileSize: 5 * 1024 * 1024 * 1024 }`
|
||||
|
||||
### 3. ⚠️ 宿主机Nginx(需要手动配置)
|
||||
- 如果使用宿主机Nginx作为反向代理
|
||||
- 必须在 `location /` 块中添加 `client_max_body_size 5G;`
|
||||
- 否则上传会在64MB时失败(Nginx默认限制)
|
||||
|
||||
## 故障排查
|
||||
|
||||
### 上传文件提示413错误
|
||||
|
||||
**问题**:上传大于64MB的文件时失败,浏览器控制台显示 `413 Payload Too Large`
|
||||
|
||||
**原因**:宿主机Nginx的 `client_max_body_size` 限制(默认1MB或64MB)
|
||||
|
||||
**解决方案**:
|
||||
1. 找到宿主机Nginx配置文件(通常是 `/etc/nginx/sites-available/` 或 `/www/server/panel/vhost/nginx/`)
|
||||
2. 在 `location /` 块中添加:
|
||||
```nginx
|
||||
client_max_body_size 5G;
|
||||
proxy_read_timeout 3600s;
|
||||
proxy_send_timeout 3600s;
|
||||
proxy_connect_timeout 3600s;
|
||||
```
|
||||
3. 测试并重载Nginx:
|
||||
```bash
|
||||
nginx -t
|
||||
nginx -s reload
|
||||
```
|
||||
|
||||
### 上传进度
|
||||
|
||||
前端已实现实时上传进度显示(使用axios的 `onUploadProgress`),无需额外配置。
|
||||
|
||||
## 存储配置
|
||||
|
||||
系统支持两种存储方式:
|
||||
|
||||
### 本地存储
|
||||
- 文件存储在:`backend/local-storage/`
|
||||
- 可设置用户配额限制
|
||||
- 适合中小型部署
|
||||
|
||||
### SFTP存储
|
||||
- 用户可配置自己的SFTP服务器
|
||||
- 支持HTTP直接下载(配置 `http_download_base_url`)
|
||||
- 适合大规模部署
|
||||
|
||||
## 安全建议
|
||||
|
||||
1. **使用HTTPS**:生产环境务必配置SSL证书
|
||||
2. **定期备份数据库**:`backend/data.db` 包含所有用户数据
|
||||
3. **限制管理员账号**:定期审查用户权限
|
||||
4. **配置防火墙**:只开放必要的端口(80, 443)
|
||||
|
||||
## 技术支持
|
||||
|
||||
如有问题,请查看日志:
|
||||
|
||||
```bash
|
||||
# 后端日志
|
||||
docker logs wanwanyun-backend
|
||||
|
||||
# 前端日志
|
||||
docker logs wanwanyun-frontend
|
||||
|
||||
# Nginx日志
|
||||
tail -f /www/wwwlogs/your-domain.log
|
||||
tail -f /www/wwwlogs/your-domain.error.log
|
||||
```
|
||||
Reference in New Issue
Block a user