This commit is contained in:
@@ -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
|
||||
|
||||
@@ -49,6 +49,7 @@ server {
|
||||
application/javascript
|
||||
application/xml
|
||||
text/css
|
||||
text/javascript
|
||||
text/plain
|
||||
text/xml
|
||||
image/svg+xml;
|
||||
|
||||
@@ -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 \
|
||||
|
||||
Reference in New Issue
Block a user