添加了完整的 Docker 部署方案,包括: - 创建 .env.example 环境变量配置模板文件 - 新增 docker-compose.yml 用于全栈服务编排 - 为前后端分别创建 Dockerfile 实现容器化部署 - 添加 nginx.conf 配置前端反向代理 - 在 README.md 中详细说明 Docker 部署流程 - 集成 Celery 任务队列支持异步处理 - 配置多数据库服务 (MongoDB, MySQL, Redis) 的连接 - 实现健康检查和服务依赖管理
47 lines
1.3 KiB
Nginx Configuration File
47 lines
1.3 KiB
Nginx Configuration File
# ============================================================
|
|
# FilesReadSystem Nginx 配置
|
|
# 反向代理 API 请求到后端
|
|
# ============================================================
|
|
|
|
server {
|
|
listen 80;
|
|
server_name localhost;
|
|
|
|
# 前端静态文件
|
|
root /usr/share/nginx/html;
|
|
index index.html;
|
|
|
|
# SPA 支持 - 所有请求都尝试返回 index.html
|
|
location / {
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
|
|
# 静态资源缓存
|
|
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
|
expires 1y;
|
|
add_header Cache-Control "public, immutable";
|
|
}
|
|
|
|
# API 反向代理到后端
|
|
location /api/ {
|
|
proxy_pass http://backend:8000/api/;
|
|
proxy_http_version 1.1;
|
|
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_connect_timeout 60s;
|
|
proxy_send_timeout 60s;
|
|
proxy_read_timeout 60s;
|
|
}
|
|
|
|
# 文件上传代理
|
|
location /uploads/ {
|
|
proxy_pass http://backend:8000/uploads/;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
client_max_body_size 100M;
|
|
}
|
|
} |