From 9dc01e24115e7980b7d39a8ed3bfa1015a60aa31 Mon Sep 17 00:00:00 2001 From: wangbo Date: Tue, 4 Aug 2026 21:22:49 +0800 Subject: [PATCH] =?UTF-8?q?fix(deploy):=20=E8=A1=A5=E9=BD=90=20Nuxt=20?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E5=8E=8B=E7=BC=A9=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 ++ easyai-proxy.conf.sample | 1 + scripts/test-deployment-public-url.sh | 16 ++++++++++++++++ 3 files changed, 19 insertions(+) diff --git a/README.md b/README.md index cafbbd0..6f44bc1 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,8 @@ CONFIG_TRUSTED_PROXY=127.0.0.1,10.0.0.0/8 新的 `easyai-proxy.conf.sample` 会为 `/api/` 和 `/mcp` 转发保留客户端 authority 中的显式端口,并补齐 `X-Forwarded-Host`、`X-Forwarded-Port`;`/api/` 继续发送 `X-Original-Prefix: /api`。脚本不会改写已经生成的本地 Nginx 配置,旧部署可先通过显式 `CONFIG_PUBLIC_API_BASE_URL` 生效,再按模板手工同步代理 Header。 +模板同时为 JSON、CSS、`application/javascript` 和 Nuxt 常用的 `text/javascript` 开启 Gzip;`text/event-stream` 未加入压缩类型,SSE 和 WebSocket 保持流式传输。已经生成的域名配置不会随模板自动更新,旧部署需要手工把 `text/javascript` 加入现有 `gzip_types`,执行 `nginx -t` 成功后再无中断 reload。 + `https.sh` 单独执行时也可以跳过域名选择: ```bash diff --git a/easyai-proxy.conf.sample b/easyai-proxy.conf.sample index 50cbd8f..5997790 100644 --- a/easyai-proxy.conf.sample +++ b/easyai-proxy.conf.sample @@ -49,6 +49,7 @@ server { application/javascript application/xml text/css + text/javascript text/plain text/xml image/svg+xml; diff --git a/scripts/test-deployment-public-url.sh b/scripts/test-deployment-public-url.sh index 9e00dab..298c102 100755 --- a/scripts/test-deployment-public-url.sh +++ b/scripts/test-deployment-public-url.sh @@ -34,6 +34,20 @@ reset_case() { demo.example.com.conf } +assert_compression_config() { + local config_file="$1" + grep -q '^ gzip on;' "$config_file" + grep -q '^ gzip_vary on;' "$config_file" + grep -q '^ gzip_min_length 1024;' "$config_file" + grep -q '^ application/javascript$' "$config_file" + grep -q '^ text/css$' "$config_file" + grep -q '^ text/javascript$' "$config_file" + if grep -q 'text/event-stream' "$config_file"; then + echo "Unexpected SSE compression type in $config_file" >&2 + return 1 + fi +} + sed -i.bak 's/^SERVER_HTTP_PORT=.*/SERVER_HTTP_PORT=4100/' .env.sample rm -f .env.sample.bak DEPLOY_NON_INTERACTIVE=1 \ @@ -60,6 +74,7 @@ grep -q 'proxy_set_header X-Forwarded-Host $easyai_forwarded_host;' demo.example grep -q 'proxy_set_header X-Forwarded-Port $server_port;' demo.example.com.conf grep -q "proxy_set_header X-Original-Prefix '/api';" demo.example.com.conf grep -q 'location = /api {' demo.example.com.conf +assert_compression_config demo.example.com.conf # 直接验证 https.sh 的缺省配置生成函数会采用完整模板,而不是只代理 3010。 eval "$(awk ' @@ -74,6 +89,7 @@ grep -q 'location /api/ {' easyai-proxy.conf grep -q 'proxy_pass http://127.0.0.1:3001/;' easyai-proxy.conf grep -q 'location /socket.io {' easyai-proxy.conf grep -q 'proxy_set_header X-Forwarded-Host $easyai_forwarded_host;' easyai-proxy.conf +assert_compression_config easyai-proxy.conf reset_case DEPLOY_NON_INTERACTIVE=1 \