面板「测试」报 minimax unknown model 'test' (2013) 的根因:1.0.43 为当时的 空 body 探测兜底,在 conf/nginx.conf 的 /_upstream_test/ 注入了 model=test 的 最小 dummy 体;而 nginx proxy_set_body 是无条件覆盖——把面板发来的「第一个 登记模型」探测体整个换掉,严格校验模型名的厂商一律误报「不通」(健康徽章因 4xx 算存活仍显示正常,二者口径不一致)。测试模板本就无此行,所以本机回归全绿 ——典型的 conf/模板漂移,本次连 gateway 模板里同款遗留一并清掉。 - conf/nginx.conf + tests/gateway/nginx.conf.in:删注入行,注释改写成「别加回来」的告诫 - tests/llm/e2e.sh【11】:动态闸(探测体原样到靶机)+ 静态闸(生产 conf 探测块禁 proxy_set_body) - CLAUDE.md 排障表补一行 llm 264 / gateway 108 全绿
123 lines
4.7 KiB
Plaintext
123 lines
4.7 KiB
Plaintext
# ============================================================================
|
||
# 域名网关 · 本机回归配置模板(**不是**仓库里的生产配置 conf/nginx.conf)
|
||
#
|
||
# 由 tests/run.sh 渲染:@MODULE@ / @REPO@ / @RUN@ 三个占位符会替换成绝对路径。
|
||
# **不要把这个模板直接交给 nginx**(占位符没替换会 load_module 失败)。
|
||
#
|
||
# 与生产配置的差异(均因本机 nginx 编译时关闭了 rewrite 模块):
|
||
# * 无 set / return / error_page 重定向
|
||
# * 端口 18080(转发) / 18081(靶机) / 18082(管理)
|
||
# * 状态目录 @RUN@/data —— 独立目录,**绝不碰生产 data/**
|
||
# ============================================================================
|
||
|
||
load_module @MODULE@;
|
||
|
||
worker_processes 2;
|
||
error_log @RUN@/logs/error.log info;
|
||
pid @RUN@/logs/nginx.pid;
|
||
|
||
events {
|
||
worker_connections 1024;
|
||
}
|
||
|
||
http {
|
||
default_type application/json;
|
||
|
||
log_format main '$remote_addr "$request" $status backend=$proxy_backend_addr';
|
||
access_log @RUN@/logs/access.log main;
|
||
|
||
sendfile on;
|
||
keepalive_timeout 65;
|
||
|
||
ipass_state state 10m;
|
||
ipass_data_dir @RUN@/data;
|
||
|
||
# ---- 靶机:模拟内网后端(e2e 断言返回体里的 "from":"backend")----
|
||
server {
|
||
listen 18081;
|
||
server_name _;
|
||
root @REPO@/tests/gateway/backend;
|
||
location / { }
|
||
}
|
||
|
||
# ---- 转发 server ----
|
||
server {
|
||
listen 18080;
|
||
# 本机 nginx 未编 PCRE,不能用正则 server_name。
|
||
# 无妨:模块自己从 Host 头解析子域名,不依赖 nginx 的捕获变量。
|
||
server_name _;
|
||
|
||
location / {
|
||
ipass_proxy on;
|
||
proxy_pass http://$proxy_backend_addr;
|
||
proxy_http_version 1.1;
|
||
proxy_set_header Host $host;
|
||
proxy_set_header X-Real-IP $remote_addr;
|
||
proxy_connect_timeout 5s;
|
||
proxy_read_timeout 300s;
|
||
}
|
||
}
|
||
|
||
# ---- 管理 server ----
|
||
server {
|
||
listen 18082;
|
||
server_name proxy-api.yourdomain.com localhost;
|
||
|
||
client_max_body_size 2m;
|
||
# 必须大于最大 API 请求体,否则 body 落临时文件 → 模块读不到(表现为「参数缺失」)
|
||
client_body_buffer_size 1m;
|
||
|
||
# 与生产 conf 同构:路由器反代场景下保持 Location 相对路径
|
||
absolute_redirect off;
|
||
port_in_redirect off;
|
||
|
||
# 与生产 conf 同构:/admin 进总览页,/admin/ 下是其余页面与静态资源
|
||
#
|
||
# **不发版不重启也能修好缓存**:所有 HTML / CSS / JS 都加
|
||
# `Cache-Control: no-store`(expires -1 + add_header),让浏览器
|
||
# 每次发版后必重新拉。文件本身都不大(HTML<5KB,CSS<10KB,JS<15KB),
|
||
# 无缓存的性能影响可忽略。不加的话:**用户浏览器会一直用发版前的
|
||
# 旧 JS**,管理台表单看不到新字段就是典型表现。
|
||
location = /admin {
|
||
default_type text/html;
|
||
alias @REPO@/www/overview.html;
|
||
expires -1;
|
||
add_header Cache-Control "no-store" always;
|
||
}
|
||
# `/admin/`(末尾斜杠、后面无字符)→ nginx 把请求 URI 拼到 alias 后
|
||
# 变成「打开 alias 文件/目录」,实测 alias 后空 URI + index 拼出
|
||
# `overview.htmlindex.html`(错误 500)。**最干净**:内部重定向到
|
||
# `/admin/overview.html`,重新走 location 匹配(落到 `= /admin` 那条)。
|
||
location = /admin/ {
|
||
rewrite ^ /admin/overview.html last;
|
||
}
|
||
location /admin/ {
|
||
alias @REPO@/www/;
|
||
expires -1;
|
||
add_header Cache-Control "no-store" always;
|
||
}
|
||
|
||
location /api/ {
|
||
ipass_api on;
|
||
}
|
||
|
||
# 上游连通性测试:/api/admin/upstreams/test 内部重定向到这里
|
||
# (与生产 conf 同套:proxy_pass 复用 $llm_*,探测体原样转发,状态透传)
|
||
location /_upstream_test/ {
|
||
internal;
|
||
proxy_pass $llm_target;
|
||
proxy_http_version 1.1;
|
||
proxy_pass_request_headers off;
|
||
proxy_set_header Host $llm_host;
|
||
proxy_set_header Authorization $llm_auth;
|
||
proxy_set_header Content-Type $http_content_type;
|
||
proxy_set_header Accept $http_accept;
|
||
# 探测体由管理台原样发来(含登记模型),不注入任何覆盖体——
|
||
# 见 conf/nginx.conf 同 location 的告诫注释与 llm e2e【11】静态闸。
|
||
proxy_connect_timeout 5s;
|
||
proxy_send_timeout 15s;
|
||
proxy_read_timeout 15s;
|
||
}
|
||
}
|
||
}
|