From e94915ced398565a7248d3567609914a8b8778e1 Mon Sep 17 00:00:00 2001 From: ouyangxq <775153912@qq.com> Date: Sun, 20 Sep 2026 09:17:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nginx/default.conf.template | 12 ++++++++++++ src/deployment/nginxConfig.test.ts | 7 ++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/nginx/default.conf.template b/nginx/default.conf.template index 3688b5f7..24d470dc 100644 --- a/nginx/default.conf.template +++ b/nginx/default.conf.template @@ -30,6 +30,18 @@ server { proxy_set_header X-Forwarded-Proto $scheme; } + # 墨家测量设备使用独立 OpenAPI 前缀,直接转发到国内 Gateway。 + # 该入口不经过 Admin 前端路由,供设备以固定 AppKey/HMAC 调用。 + location /openapi/ { + client_max_body_size 55m; + proxy_pass ${API_UPSTREAM}; + proxy_http_version 1.1; + proxy_set_header Host $proxy_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; + } + # 海外业务使用独立 Gateway;将浏览器前缀改写为 Gateway 的 /api 前缀。 location /overseas-api/ { client_max_body_size 55m; diff --git a/src/deployment/nginxConfig.test.ts b/src/deployment/nginxConfig.test.ts index 55caf51f..c1bc11b2 100644 --- a/src/deployment/nginxConfig.test.ts +++ b/src/deployment/nginxConfig.test.ts @@ -11,7 +11,7 @@ const dockerfile = readFileSync(resolve(process.cwd(), 'Dockerfile'), 'utf8') describe('admin nginx deployment config', () => { it('allows 50 MiB files plus multipart overhead through both bounded API proxies', () => { - expect(config.match(/client_max_body_size 55m;/g)).toHaveLength(2) + expect(config.match(/client_max_body_size 55m;/g)).toHaveLength(3) expect(config).not.toContain('client_max_body_size 12m;') expect(config).not.toContain('client_max_body_size 0;') }) @@ -75,4 +75,9 @@ describe('admin nginx deployment config', () => { expect(jenkinsfile).toContain('export DOCKER_CONFIG="${WORKSPACE}@tmp/docker-auth"') expect(jenkinsfile).toContain('--build-arg VITE_CLIENT_WEB_URL="${CLIENT_WEB_URL:-https://dev-app.buggoglobal.com/}"') }) + + it('proxies Mojia measurement OpenAPI requests to the domestic gateway', () => { + expect(config).toContain('location /openapi/') + expect(config).toContain('location /openapi/ {\n client_max_body_size 55m;\n proxy_pass ${API_UPSTREAM};') + }) }) -- 2.54.0