Files
opendance-web/deploy/proxy/nginx.conf.example
T
zijunchiang 8c76b0a599 feat(web): 移除 Docker 与反代部署,改为 Linux 业务服务并自带管理端托管
需求变更:Web 端只保留业务需求,反向代理交由另外的服务处理,
本项目仅提供 IIS / nginx 反代说明文档,不部署反代。

主要改动:
- web-server: 新增管理端静态托管(ADMIN_DIR、SPA 深链接回退),
  反代因此只需一条全匹配转发规则;新增 adminDir 配置项
- deploy/install.sh: 删除 nginx 安装与站点配置逻辑,改为原生 Linux
  服务部署(systemd → OpenRC → SysVinit → 后台进程四级降级),
  打印反代交接指引
- deploy/ctl.sh: 启停/状态/日志脚本
- deploy/proxy/: 新增反代说明文档(README.md、nginx.conf.example、
  web.config.example),标注上传上限与超时必须同步调整
- 删除 deploy/nginx/、web-server/admin/nginx.conf、Dockerfile、
  docker-compose.yml、.dockerignore
- scripts/package-release.sh: 锚定排除规则 + 产物完整性校验
- 文档同步:README.txt、DSH.md、project.yaml、tasks/008、tasks/010
2026-09-15 01:25:19 +08:00

123 lines
4.4 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ============================================================
# OpenDance Studio Web 服务端 —— nginx 反向代理样例
#
# 说明:本 Web 端不自带反向代理。本文件是**给你的反代服务参考**的配置样例,
# 由部署 `deploy/install.sh` 之外的反代负责人使用。
#
# 特点:后端(NestJS)自带管理端页面与 SPA 回退,因此这里
# 只需一个全匹配 location 把请求整体转发过去即可,
# 不需要 root/try_files 托管静态文件。
#
# 安装:
# Debian/Ubuntu: /etc/nginx/sites-available/opendance.conf(再软链到 sites-enabled/)
# RHEL 系: /etc/nginx/conf.d/opendance.conf
# 校验并重载: nginx -t && systemctl reload nginx
# ============================================================
upstream opendance_api {
# 后端地址:同机用 127.0.0.1;异机改成实际 IP,并在后端放防火墙
server 127.0.0.1:3000;
keepalive 16;
}
server {
listen 80;
listen [::]:80;
server_name your.domain.com; # 改成实际域名或 _
# 字符集:管理端与 API 都是 UTF-8
charset utf-8;
# ★ 上传上限:后端默认允许 512 MiB,nginx 默认仅 1 MB,
# 不改会导致 VRM / FBX 等大文件上传直接 413。
client_max_body_size 512m;
client_body_timeout 300s;
access_log /var/log/nginx/opendance.access.log;
error_log /var/log/nginx/opendance.error.log;
# ---- 全部请求转发给后端 ----
# 管理端页面、前端路由深链接、/api、/health、/static、/contracts
# 全部由后端处理,所以这里只需一条规则。
location / {
proxy_pass http://opendance_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;
# 配合 upstream keepalive,避免 Connection: close
proxy_set_header Connection "";
# ★ 超时:大文件上传与关键点序列下载都可能较慢
proxy_connect_timeout 30s;
proxy_send_timeout 300s;
proxy_read_timeout 300s;
# 大文件直接透传,不在代理层落盘
proxy_request_buffering off;
proxy_buffering off;
}
# 健康检查可单独放开日志噪音(可选)
location = /health {
proxy_pass http://opendance_api/health;
proxy_http_version 1.1;
proxy_set_header Host $host;
access_log 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;
# 若前端资源由后端返回,代理层不要缓存 HTML,避免升级后页面不更新
location ~* \.html$ {
proxy_pass http://opendance_api;
proxy_http_version 1.1;
proxy_set_header Host $host;
add_header Cache-Control "no-cache";
}
}
# ============================================================
# 可选:HTTPS 终止在反代(后端只监听 HTTP)
#
# server {
# listen 443 ssl;
# http2 on;
# server_name your.domain.com;
#
# ssl_certificate /etc/nginx/ssl/opendance.crt;
# ssl_certificate_key /etc/nginx/ssl/opendance.key;
# ssl_protocols TLSv1.2 TLSv1.3;
#
# client_max_body_size 512m;
#
# location / {
# proxy_pass http://opendance_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_send_timeout 300s;
# proxy_read_timeout 300s;
# proxy_request_buffering off;
# }
# }
# ============================================================
# ============================================================
# 可选:本服务未内置登录认证,如需公网访问请在反代加一层防护
#
# location / {
# auth_basic "OpenDance Studio";
# auth_basic_user_file /etc/nginx/.htpasswd; # htpasswd -c 生成
# proxy_pass http://opendance_api;
# ...
# }
# ============================================================