# sub.tksea.top portal routing example
#
# 说明：
# - /portal/ 是新的通用多模型接入中心地址
# - /kimi-portal 与 /kimi-portal/ 保留 302 跳转，避免旧链接失效
# - /portal-proxy/ 是页面调用宿主用户态 API 的同域代理
# - /portal-admin-api/ 是页面调用 CRM 管理 API 的同域代理
# - /kimi/ 与 /kimi-v1/ 继续保留，兼容旧的 Kimi 专用客户端配置

location = /portal {
    return 302 /portal/;
}

location = /portal/admin {
    return 302 /portal/admin/;
}

location = /kimi-portal {
    return 302 /portal/;
}

# BEGIN sub2api-portal
location /portal/ {
    alias /var/www/sub2api-portal/;
    index index.html;
    try_files $uri $uri/ /portal/index.html;
}

location /portal-proxy/ {
    proxy_pass http://127.0.0.1:18169/;
    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_http_version 1.1;
}

location /portal-admin-api/ {
    proxy_pass http://127.0.0.1:18173/;
    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_http_version 1.1;
}

location /kimi-portal/ {
    return 302 /portal/;
}

location /kimi-portal-proxy/ {
    proxy_pass http://127.0.0.1:18169/;
    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_http_version 1.1;
}

location /kimi/ {
    proxy_pass http://127.0.0.1:18169/;
    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_http_version 1.1;
}

location /kimi-v1/ {
    proxy_pass http://127.0.0.1:18169/v1/;
    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_http_version 1.1;
}
# END sub2api-portal
