Files
Genarrative/deploy/nginx/genarrative-release-origin.conf
T
kdletters cf19241544 游戏发行入口改为服务端按模板派生
- 后台审核页删除「发行入口」输入框与前端 HTTPS 校验,审核请求只提交结论与公开修订号
- api-server 新增 GENARRATIVE_GAME_DISTRIBUTION_RELEASE_ENTRY_TEMPLATE 模板配置,审核通过时读版本取 gameId 并派生该游戏独立来源地址
- 模板缺 {gameId}、生产未配置模板、gameId 非主机安全字符或派生结果非法时审核通过失败关闭,非生产未配置时回落本地回环发行网关
- 同步更新发行来源 nginx 模板与说明、两份 api-server 环境变量样例、平台与运维主规范、发行里程碑实施计划和决策记录
- 真实栈 e2e 脚本不再传 entryUrl,并断言审核结果里的入口为服务端派生值
2026-09-23 21:33:42 +08:00

82 lines
3.2 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.
# 游戏发行来源(每游戏独立 origin)
#
# 部署前替换:
# 1) `games.example.com` 为真实发行域,并为 `*.games.example.com` 配置通配 DNS
# 与通配 TLS 证书;
# 2) `ssl_certificate` / `ssl_certificate_key` 指向该通配证书;
# 3) upstream 端口与 api-server 实际监听一致。
#
# 设计约定:
# - 每个已公开游戏使用自己的子域:`https://<gameId>.games.example.com/`;
# - 该来源只把请求映射到发行网关
# `/api/game-distribution/releases/<gameId>/…`,平台 API、后台、SPA 与上传
# 接口都不在这个来源上暴露;
# - 发行来源从不使用 Cookie:带 Cookie 的请求直接 403,转发前也会清空 Cookie;
# - `X-Content-Type-Options` / CORP / 无凭据 CORS / HTML CSP / 内容类型白名单由
# api-server 发行网关设置,这里不覆盖,避免两层策略漂移;
# - 公开版本切换与下架由后端 `publication_revision` CAS 决定,边缘只做按主机映射。
upstream genarrative_release_api {
server 127.0.0.1:8082;
keepalive 32;
}
server {
listen 80;
server_name ~^(?<game_id>[a-z0-9_]+)\.games\.example\.com$;
location /.well-known/acme-challenge/ {
root /var/www/html;
}
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl http2;
server_name ~^(?<game_id>[a-z0-9_]+)\.games\.example\.com$;
ssl_certificate /etc/letsencrypt/live/games.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/games.example.com/privkey.pem;
access_log /var/log/nginx/genarrative-release.access.log;
error_log /var/log/nginx/genarrative-release.error.log warn;
# 发行文件是公开静态资源,从不携带平台 Cookie。带上 Cookie 的请求说明它落在
# 平台会话来源上,直接拒绝,避免发行内容被主站同源脚本读取。
if ($http_cookie) {
return 403;
}
# 子域根路径直接服务该游戏的 index.html,游戏内其余资源按相对路径原样交给
# 发行网关;审核通过时 api-server 按发行入口模板派生的 entryUrl 就是
# https://<gameId>.games.example.com/。
location = / {
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_set_header X-Request-Id $request_id;
proxy_set_header Cookie "";
proxy_pass http://genarrative_release_api/api/game-distribution/releases/$game_id/index.html;
proxy_read_timeout 60s;
proxy_send_timeout 60s;
}
location / {
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_set_header X-Request-Id $request_id;
proxy_set_header Cookie "";
proxy_pass http://genarrative_release_api/api/game-distribution/releases/$game_id$request_uri;
proxy_read_timeout 60s;
proxy_send_timeout 60s;
}
}