# ============================================================ # OpenDance Studio —— nginx 站点配置(Linux 原生部署) # # 一个站点同时提供: # / 管理端静态站点(React 构建产物) # /api/ NestJS API 反向代理 # /health 健康检查反向代理 # /static/ 上传文件(模型 / 音频 / 关键点),由 API 提供 # /contracts/ 契约快照(只读,方便另两端查阅) # # 安装位置:/etc/nginx/sites-available/opendance.conf # (并软链到 /etc/nginx/sites-enabled/) # ============================================================ server { listen 80; listen [::]:80; server_name __SERVER_NAME__; # 上传上限:单个 VRM / FBX 可达 512 MiB,必须与后端 UPLOAD_MAX_BYTES 一致 client_max_body_size 512m; client_body_timeout 300s; # 管理端静态站点 root __APP_DIR__/admin; index index.html; charset utf-8; # ---- 管理端 SPA ---- location / { try_files $uri $uri/ /index.html; } # Vite 产物带内容哈希,可长缓存 location /assets/ { expires 30d; add_header Cache-Control "public, immutable"; try_files $uri =404; } # ---- API 反向代理 ---- location /api/ { proxy_pass http://__API_HOST__:__API_PORT__; 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 30s; proxy_send_timeout 300s; proxy_read_timeout 300s; proxy_request_buffering off; } location = /health { proxy_pass http://__API_HOST__:__API_PORT__/health; proxy_http_version 1.1; proxy_set_header Host $host; access_log off; } # ---- 上传文件 ---- location /static/ { proxy_pass http://__API_HOST__:__API_PORT__; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; expires 7d; add_header Cache-Control "public"; } # ---- 契约快照(只读)---- location /contracts/ { alias __APP_DIR__/contracts/; autoindex on; default_type text/plain; } # 隐藏文件一律拒绝 location ~ /\. { deny all; access_log off; log_not_found off; } gzip on; gzip_types text/plain text/css application/json application/javascript application/x-ndjson text/xml application/xml image/svg+xml; gzip_min_length 1024; }