9.2 KiB
9.2 KiB
🐳 飞牛 NAS 使用说明 - Docker 部署指南
📦 项目简介
本项目将飞牛 NAS 使用说明静态网站打包成 Docker 镜像,方便快速部署和分享。
网站包含:
- ✅ 飞牛 NAS 使用说明
- ✅ 龙虾盒子使用指南
- ✅ 挂机宝使用指南
- ✅ Win 小主机说明
- ✅ 常见问题解答
🚀 快速部署
方法一:使用部署脚本(推荐)
Windows 系统
# 双击运行
deploy.bat
或在命令行中执行:
.\deploy.bat
Linux/Mac 系统
# 赋予执行权限
chmod +x deploy.sh
# 运行脚本
./deploy.sh
方法二:使用 Docker 命令
# 1. 构建镜像
docker build -t feiniu-usage-guide:latest .
# 2. 运行容器
docker run -d -p 8080:80 --name feiniu-usage-guide feiniu-usage-guide:latest
方法三:使用 Docker Compose
# 1. 启动服务
docker-compose up -d
# 2. 查看状态
docker-compose ps
# 3. 停止服务
docker-compose down
🌐 访问方式
部署完成后,在浏览器中访问:
- 本地访问:http://localhost:8080
- 局域网访问:http://<服务器 IP>:8080
📁 网站结构
使用说明/
├── index.html # 首页
├── css/
│ └── style.css # 样式文件
├── js/
│ └── main.js # JavaScript 文件
└── pages/ # 子页面
├── usage-guide.html # 使用说明
├── longxiahezi.html # 龙虾盒子
├── longxiahezi-guide.html # 龙虾盒子指南
├── guajibao.html # 挂机宝
├── guajibao-guide.html # 挂机宝指南
├── win-overview.html # Win 小主机概览
├── win-guide.html # Win 小主机指南
├── faq.html # 常见问题
└── support.html # 技术支持
🔧 管理命令
Docker 容器管理
# 查看容器状态
docker ps
# 查看日志
docker logs feiniu-usage-guide
# 实时查看日志
docker logs -f feiniu-usage-guide
# 停止容器
docker stop feiniu-usage-guide
# 启动容器
docker start feiniu-usage-guide
# 重启容器
docker restart feiniu-usage-guide
# 删除容器
docker rm -f feiniu-usage-guide
# 查看容器详情
docker inspect feiniu-usage-guide
镜像管理
# 查看镜像
docker images feiniu-usage-guide
# 删除镜像
docker rmi feiniu-usage-guide:latest
# 导出镜像
docker save -o feiniu-usage-guide.tar feiniu-usage-guide:latest
# 导入镜像
docker load -i feiniu-usage-guide.tar
📊 镜像信息
镜像大小
docker images feiniu-usage-guide
预计大小:约 20-30MB(使用 nginx:alpine 基础镜像)
镜像特点
- ✅ 轻量级:基于 nginx:alpine,镜像小巧
- ✅ 高性能:Nginx 提供高效的静态文件服务
- ✅ 健康检查:内置健康检查机制
- ✅ 自动重启:容器异常自动重启
- ✅ Gzip 压缩:启用 Gzip 压缩,加快加载速度
- ✅ 缓存优化:静态资源缓存优化
🌍 网络配置
修改访问端口
# 默认使用 8080 端口
# 如需修改为其他端口(如 8081),修改端口映射:
docker run -d -p 8081:80 --name feiniu-usage-guide feiniu-usage-guide:latest
局域网访问
部署完成后,局域网内的其他设备可以通过以下方式访问:
http://<服务器 IP 地址>:8080
远程访问
如需从外网访问,需要:
-
配置路由器端口转发(Port Forwarding)
- 将外部端口 8080 转发到服务器 IP:8080
-
使用内网穿透工具
- frp
- ngrok
- tailscale
-
配置公网 IP 和域名
- 申请公网 IP
- 配置 DNS 解析
- 使用 Nginx 反向代理
🔐 安全加固(生产环境)
1. 添加 HTTP 认证
创建密码文件:
# 生成密码文件
docker run --rm httpd:2.4 htpasswd -Bbn admin yourpassword > .htpasswd
修改 nginx.conf 添加认证:
location / {
auth_basic "Restricted Access";
auth_basic_user_file /etc/nginx/.htpasswd;
try_files $uri $uri/ /index.html;
}
2. 启用 HTTPS
使用 Let's Encrypt 免费 SSL 证书:
# 使用 certbot 获取证书
docker run -it --rm \
-v /path/to/certs:/etc/letsencrypt \
certbot/certbot certonly --standalone -d yourdomain.com
修改 nginx.conf 配置 SSL:
server {
listen 443 ssl http2;
server_name yourdomain.com;
ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;
# ... 其他配置
}
3. 限制 IP 访问
在 nginx.conf 中添加:
location / {
# 只允许特定 IP 访问
allow 192.168.1.0/24;
deny all;
try_files $uri $uri/ /index.html;
}
🐛 故障排查
问题 1:容器无法启动
症状:docker run 命令执行后容器立即退出
解决方法:
# 查看容器日志
docker logs feiniu-usage-guide
# 检查配置文件语法
docker run --rm -v $(pwd):/app nginx:alpine nginx -t
# 查看容器详情
docker inspect feiniu-usage-guide
问题 2:端口被占用
症状:Address already in use 错误
解决方法:
# Windows 查看端口占用
netstat -ano | findstr :8080
# Linux/Mac 查看端口占用
lsof -i :8080
# 修改端口映射
docker run -d -p 8081:80 --name feiniu-usage-guide feiniu-usage-guide:latest
问题 3:无法访问页面
症状:浏览器无法打开 http://localhost:8080
解决方法:
- 检查容器是否运行:
docker ps - 检查防火墙设置
- 查看 nginx 日志:
docker logs feiniu-usage-guide - 测试容器内部:
docker exec feiniu-usage-guide wget -q -O - http://localhost
问题 4:页面显示不正常
症状:CSS/JS 文件加载失败
解决方法:
- 检查文件路径是否正确
- 查看浏览器开发者工具的控制台
- 确认 nginx 配置中的 MIME 类型
- 重新构建镜像:
docker build -t feiniu-usage-guide:latest .
📈 性能优化
1. 启用 Gzip 压缩
已在 nginx.conf 中配置:
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript;
2. 配置浏览器缓存
已在 nginx.conf 中配置:
# 静态资源缓存 1 年
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
# HTML 文件不缓存
location ~* \.html$ {
expires -1;
add_header Cache-Control "no-cache, no-store, must-revalidate";
}
3. 限制并发连接
在 nginx.conf 中添加:
worker_connections 1024;
worker_processes auto;
4. 启用 HTTP/2
修改 nginx.conf:
listen 443 ssl http2;
🎯 最佳实践
1. 定期更新基础镜像
# 拉取最新的基础镜像
docker pull nginx:alpine
# 重新构建镜像(不使用缓存)
docker build --no-cache -t feiniu-usage-guide:latest .
# 重启容器
docker restart feiniu-usage-guide
2. 使用健康检查
已在 docker-compose.yml 中配置:
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost/"]
interval: 30s
timeout: 3s
retries: 3
start_period: 5s
3. 日志轮转
在 docker-compose.yml 中添加:
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
4. 资源限制
# 限制内存和 CPU 使用
docker run -d -p 8080:80 \
--memory="256m" \
--cpus="0.5" \
--name feiniu-usage-guide \
feiniu-usage-guide:latest
5. 数据备份
# 备份网站文件
tar -czf usage-guide-backup.tar.gz 使用说明/
# 备份 Docker 镜像
docker save -o feiniu-usage-guide-backup.tar feiniu-usage-guide:latest
📞 获取帮助
官方文档
常见问题
查看网站内的 常见问题 页面
技术支持
如有问题,请查看:
- 容器日志:
docker logs feiniu-usage-guide - 容器状态:
docker ps - 系统资源:
docker stats feiniu-usage-guide
📝 更新网站内容
当需要更新网站内容时:
方法 1:重新构建镜像
# 1. 修改 使用说明/ 目录下的文件
# 2. 重新构建镜像
docker build -t feiniu-usage-guide:latest .
# 3. 重启容器
docker restart feiniu-usage-guide
方法 2:使用卷挂载(开发环境)
修改 docker-compose.yml,取消注释:
volumes:
- ./使用说明:/usr/share/nginx/html:ro
然后重启服务:
docker-compose down
docker-compose up -d
🎉 恭喜!
您已成功部署飞牛 NAS 使用说明网站!
现在可以:
- ✅ 访问 http://localhost:8080 查看网站
- ✅ 分享给团队成员使用
- ✅ 随时更新网站内容
- ✅ 部署到生产环境
版本: 1.0
更新日期: 2026-03-31
维护团队: 泽枢云启