需求 1:管理端端口与软件 API 端口分离 - 软件 API 端口 PORT(默认 3000)只提供 /api、/health、/static、/contracts, 不提供管理页面(未命中路径 404);管理端端口 ADMIN_PORT(默认 3001) 提供管理页面与全部接口;ADMIN_HOST 可单独限制管理端来源 - main.ts 同进程监听两个端口,用 req.socket.localPort 区分端口行为; ADMIN_PORT=PORT 为单端口兼容模式(只创建一个 server,无 EADDRINUSE) - 端口非法在生产环境中止启动;ADMIN_PORT=PORT 只 warn - 启动日志分别打印两个端口的访问地址 需求 2:动作数据支持 VMD(MikuMikuDance) - vmd-parser.ts:二进制解析(30 字节头 + Shift-JIS 模型名 + 111 字节/条骨骼 关键帧 + morph 段)、MMD 贝塞尔插值、GBK 模型名回退、固定 30fps - mmd-skeleton.ts:标准 MMD 骨架;静止比例从参考 PMX 骨骼段实测得到 (足首 1.43 / 膝 6.57 / 髋 11.50 / 首 16.21 / 頭 17.16,腿长 10.09) - mmd-pose.ts:FK + 两骨骼解析腿部 IK(膝盖朝正面,不可达收敛为伸直) + 左手系→右手系 Z 镜像(由真实数据对照实验确定:94.1% vs 5.9%) - retarget.ts:抽出 worldFramesToKeypointFrames(),BVH 与 VMD 共用重定向 - MotionFormat 增 vmd、扩展名映射增 .vmd;管理端上传支持 .vmd - scripts/inspect-vmd.mjs:上传前自查工具 契约:rest-api / data-models / model-formats → 0.2.0(另两库已同步逐字节一致) 验证:85 项单测通过(VMD 31 项);契约与 29 条路由一致;typecheck/build 通过; 真实样本经 HTTP 端到端:霜雪千年 2901 帧(IK 腿)、恋爱循环 4604 帧(FK 腿) 均 preprocessState=done、0 NaN、0 越界(测试数据已从数据库清理)。
106 lines
5.1 KiB
XML
106 lines
5.1 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
||
<!--
|
||
============================================================
|
||
OpenDance Studio Web 服务端 —— IIS 反向代理样例
|
||
|
||
说明:本 Web 端不自带反向代理。本文件是**给你的反代服务参考**的配置样例。
|
||
|
||
前置条件(IIS 默认都不带,需自行安装):
|
||
1. URL Rewrite 模块
|
||
https://www.iis.net/downloads/microsoft/url-rewrite
|
||
2. Application Request Routing (ARR)
|
||
https://www.iis.net/downloads/microsoft/application-request-routing
|
||
3. 启用 ARR 代理(否则会 404.4):
|
||
IIS 管理器 → 服务器节点 → Application Request Routing Cache
|
||
→ Server Proxy Settings → 勾选 Enable proxy
|
||
|
||
放置位置:IIS 站点根目录下的 web.config
|
||
|
||
后端(NestJS)同时监听两个端口,职责不同:
|
||
|
||
软件 API 端口(PORT,默认 3000)—— 给 Windows/Godot 客户端与 Android App
|
||
只有 /api、/health、/static、/contracts
|
||
管理端端口(ADMIN_PORT,默认 3001)—— 给浏览器
|
||
管理页面 + 上面全部接口
|
||
|
||
**在 IIS 里建两个站点**,把下面这份 web.config 各放一份,只改 <action> 里的端口:
|
||
站点 A(如 dance-api.example.com) → http://127.0.0.1:3000/{R:1}
|
||
站点 B(如 dance-admin.example.com)→ http://127.0.0.1:3001/{R:1}
|
||
|
||
后端自带管理端页面与 SPA 回退,所以每个站点只需一条全匹配重写规则,
|
||
不需要在 IIS 上再配置默认文档或 URL Rewrite 的 SPA 回退。
|
||
============================================================
|
||
-->
|
||
<configuration>
|
||
<system.webServer>
|
||
|
||
<rewrite>
|
||
<rules>
|
||
<!--
|
||
全部请求转发给后端。
|
||
管理端站点把端口改成 3001;软件 API 站点保持 3000。
|
||
注意:软件 API 端口**不提供管理页面**,用浏览器访问它会得到 404,
|
||
这是有意设计(职责分离),不是配置错误。
|
||
-->
|
||
<rule name="OpenDanceReverseProxy" stopProcessing="true">
|
||
<match url="(.*)" />
|
||
<action type="Rewrite" url="http://127.0.0.1:3000/{R:1}" />
|
||
</rule>
|
||
</rules>
|
||
<!-- 若需要 HTTPS 终止,取消下面一段注释(IIS 侧装证书) -->
|
||
<!--
|
||
<outboundRules>
|
||
<rule name="RewriteRedirectToHttps" preCondition="IsRedirect">
|
||
<match serverVariable="RESPONSE_Location" pattern="^http://(.*)" />
|
||
<action type="Rewrite" value="https://{R:1}" />
|
||
</rule>
|
||
<preConditions>
|
||
<preCondition name="IsRedirect">
|
||
<add input="{RESPONSE_STATUS}" pattern="3\d\d" />
|
||
</preCondition>
|
||
</preConditions>
|
||
</outboundRules>
|
||
-->
|
||
</rewrite>
|
||
|
||
<security>
|
||
<requestFiltering>
|
||
<!-- ★ 上传上限 512 MiB。IIS 默认约 28.6 MB,不改大文件上传必失败(413) -->
|
||
<requestLimits maxAllowedContentLength="536870912" />
|
||
</requestFiltering>
|
||
</security>
|
||
|
||
<!-- ★ 与上一条配合:SSL 场景下请求体预读缓冲,默认仅 48 KB,不改仍会失败 -->
|
||
<serverRuntime uploadReadAheadSize="536870912" />
|
||
|
||
<!-- 保留原始 Host 头,后端日志与重定向才正确 -->
|
||
<proxy preserveHostHeader="true" />
|
||
|
||
<httpProtocol>
|
||
<customHeaders>
|
||
<remove name="X-Powered-By" />
|
||
</customHeaders>
|
||
</httpProtocol>
|
||
|
||
</system.webServer>
|
||
</configuration>
|
||
<!--
|
||
┌──────────────────────────────────────────────────────────────┐
|
||
│ 三个最常踩的坑 │
|
||
├──────────────────────────────────────────────────────────────┤
|
||
│ 0. 两个端口搞混。浏览器要访问的是**管理端端口 3001**; │
|
||
│ 客户端调用的是**软件 API 端口 3000**。指错会出现 │
|
||
│ "管理页面 404" 或 "接口全 404"。 │
|
||
│ │
|
||
│ 1. 代理超时是**服务器级**配置,不在 web.config 里。 │
|
||
│ ARR 默认 120 秒,上传大模型会中途断开。改 │
|
||
│ C:\Windows\System32\inetsrv\config\applicationHost.config │
|
||
│ 的 <webProxy> 节点: │
|
||
│ <webProxy enabled="true" timeout="00:05:00" /> │
|
||
│ 改完 iisreset 或重启 W3SVC。 │
|
||
│ │
|
||
│ 2. requestLimits 与 serverRuntime 必须**同时**改。 │
|
||
│ 只改前者,HTTPS 下仍会因 uploadReadAheadSize 太小而失败。 │
|
||
└──────────────────────────────────────────────────────────────┘
|
||
-->
|