Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
ed681d08
Commit
ed681d08
authored
Feb 13, 2026
by
yangjianbo
Browse files
feat: 整理
parent
3734abed
Changes
3
Hide whitespace changes
Inline
Side-by-side
README_CN.md
View file @
ed681d08
...
...
@@ -139,6 +139,8 @@ curl -sSL https://raw.githubusercontent.com/Wei-Shaw/sub2api/main/deploy/install
使用 Docker Compose 部署,包含 PostgreSQL 和 Redis 容器。
如果你的服务器是
**Ubuntu 24.04**
,建议直接参考:
`deploy/ubuntu24-docker-compose-aicodex.md`
,其中包含「安装最新版 Docker + docker-compose-aicodex.yml 部署」的完整步骤。
#### 前置条件
-
Docker 20.10+
...
...
deploy/docker-compose-aicodex.yml
View file @
ed681d08
# =============================================================================
#
Sub2API
Docker Compose Host Configuration (Local Build)
#
aicodex2api
Docker Compose Host Configuration (Local Build)
# =============================================================================
# Quick Start:
# 1. Copy .env.example to .env and configure
# 2. docker-compose -f docker-compose-host.yml up -d --build
# 3. Check logs: docker-compose -f docker-compose-host.yml logs -f
sub
2api
# 3. Check logs: docker-compose -f docker-compose-host.yml logs -f
aicodex
2api
# 4. Access: http://localhost:8080
#
# This configuration builds the image from source (Dockerfile in project root).
...
...
@@ -14,15 +14,14 @@
services
:
# ===========================================================================
#
Sub2API
Application
#
aicodex2api
Application
# ===========================================================================
sub2api
:
#image: weishaw/sub2api:latest
aicodex2api
:
image
:
yangjianbo/aicodex2api:latest
build
:
context
:
..
dockerfile
:
Dockerfile
container_name
:
sub
2api
container_name
:
aicodex
2api
restart
:
unless-stopped
network_mode
:
host
ulimits
:
...
...
@@ -31,7 +30,7 @@ services:
hard
:
800000
volumes
:
# Data persistence (config.yaml will be auto-generated here)
-
sub
2api_data:/app/data
-
aicodex
2api_data:/app/data
# Mount custom config.yaml (optional, overrides auto-generated config)
#- ./config.yaml:/app/data/config.yaml:ro
environment
:
...
...
@@ -54,9 +53,9 @@ services:
# Using host network: point to host/external DB by DATABASE_HOST/DATABASE_PORT
-
DATABASE_HOST=${DATABASE_HOST:-127.0.0.1}
-
DATABASE_PORT=${DATABASE_PORT:-5432}
-
DATABASE_USER=${POSTGRES_USER:-
sub
2api}
-
DATABASE_USER=${POSTGRES_USER:-
aicodex
2api}
-
DATABASE_PASSWORD=${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is required}
-
DATABASE_DBNAME=${POSTGRES_DB:-
sub
2api}
-
DATABASE_DBNAME=${POSTGRES_DB:-
aicodex
2api}
-
DATABASE_SSLMODE=disable
-
DATABASE_MAX_OPEN_CONNS=${DATABASE_MAX_OPEN_CONNS:-50}
-
DATABASE_MAX_IDLE_CONNS=${DATABASE_MAX_IDLE_CONNS:-10}
...
...
@@ -86,7 +85,7 @@ services:
# =======================================================================
# Admin Account (auto-created on first run)
# =======================================================================
-
ADMIN_EMAIL=${ADMIN_EMAIL:-admin@
sub
2api.local}
-
ADMIN_EMAIL=${ADMIN_EMAIL:-admin@
aicodex
2api.local}
-
ADMIN_PASSWORD=${ADMIN_PASSWORD:-}
# =======================================================================
...
...
@@ -152,7 +151,7 @@ services:
# ===========================================================================
postgres
:
image
:
postgres:18-alpine
container_name
:
sub
2api-postgres
container_name
:
aicodex
2api-postgres
restart
:
unless-stopped
network_mode
:
host
ulimits
:
...
...
@@ -166,9 +165,9 @@ services:
# 若不显式设置 PGDATA,则即使挂载了 postgres_data 到 /var/lib/postgresql/data,数据也不会落盘到该命名卷,
# docker compose down/up 后会触发 initdb 重新初始化,导致用户/密码等数据丢失。
-
PGDATA=/var/lib/postgresql/data
-
POSTGRES_USER=${POSTGRES_USER:-
sub
2api}
-
POSTGRES_USER=${POSTGRES_USER:-
aicodex
2api}
-
POSTGRES_PASSWORD=${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is required}
-
POSTGRES_DB=${POSTGRES_DB:-
sub
2api}
-
POSTGRES_DB=${POSTGRES_DB:-
aicodex
2api}
-
TZ=${TZ:-Asia/Shanghai}
command
:
-
"
postgres"
...
...
@@ -189,7 +188,7 @@ services:
-
"
-c"
-
"
maintenance_work_mem=${POSTGRES_MAINTENANCE_WORK_MEM:-128MB}"
healthcheck
:
test
:
[
"
CMD-SHELL"
,
"
pg_isready
-U
${POSTGRES_USER:-
sub
2api}
-d
${POSTGRES_DB:-
sub
2api}
-p
${DATABASE_PORT:-5432}"
]
test
:
[
"
CMD-SHELL"
,
"
pg_isready
-U
${POSTGRES_USER:-
aicodex
2api}
-d
${POSTGRES_DB:-
aicodex
2api}
-p
${DATABASE_PORT:-5432}"
]
interval
:
10s
timeout
:
5s
retries
:
5
...
...
@@ -201,7 +200,7 @@ services:
# ===========================================================================
redis
:
image
:
redis:8-alpine
container_name
:
sub
2api-redis
container_name
:
aicodex
2api-redis
restart
:
unless-stopped
network_mode
:
host
ulimits
:
...
...
@@ -234,7 +233,7 @@ services:
# Volumes
# =============================================================================
volumes
:
sub
2api_data
:
aicodex
2api_data
:
driver
:
local
postgres_data
:
driver
:
local
...
...
openai-passthrough-regression-checklist-20260212.md
deleted
100644 → 0
View file @
3734abed
# OpenAI 自动透传回归测试清单(2026-02-12)
## 目标
-
验证 OpenAI 账号(OAuth/API Key)“自动透传”开关在创建页与编辑页可正确开关。
-
验证开启后请求透传(仅替换认证),并保留计费/并发/审计等网关能力。
-
验证
`User-Agent`
头透传到上游,且 Usage 页面展示原始 UA(不映射、不截断)。
## 自动化测试
在仓库根目录执行:
```
bash
(
cd
backend
&&
go
test
./internal/service
-run
'OpenAIGatewayService_.*Passthrough|TestAccount_IsOpenAIPassthroughEnabled|TestAccount_IsOpenAIOAuthPassthroughEnabled'
-count
=
1
)
(
cd
backend
&&
go
test
./internal/handler
-run
OpenAI
-count
=
1
)
pnpm
--dir
frontend run typecheck
pnpm
--dir
frontend run lint:check
```
预期:
-
所有命令退出码为
`0`
。
## 手工回归场景
### 场景1:创建 OpenAI API Key 账号并开启自动透传
1.
进入管理端账号创建弹窗,平台选择 OpenAI,类型选择 API Key。
2.
打开“自动透传(仅替换认证)”开关并保存。
3.
检查创建后的账号详情。
预期:
-
`extra.openai_passthrough = true`
。
-
模型白名单/映射区域显示“不会生效”的提示。
### 场景2:编辑 OpenAI OAuth 账号开关可开可关
1.
打开已有 OpenAI OAuth 账号编辑弹窗。
2.
将“自动透传(仅替换认证)”从关切到开并保存。
3.
再次进入编辑页,将开关从开切到关并保存。
预期:
-
开启后:
`extra.openai_passthrough = true`
。
-
关闭后:
`extra.openai_passthrough`
与
`extra.openai_oauth_passthrough`
均被清理。
### 场景3:请求链路透传(含 User-Agent)
1.
使用设置为“自动透传=开启”的 OpenAI 账号发起
`/v1/responses`
请求。
2.
请求头设置
`User-Agent: codex_cli_rs/0.1.0`
(或任意自定义 UA)。
预期:
-
上游收到与下游一致的
`User-Agent`
。
-
请求体保持原样透传,仅认证头被替换为目标账号令牌。
### 场景4:Usage 页面原样显示 User-Agent
1.
进入管理端用量表(Admin Usage)与用户侧用量页(User Usage)。
2.
查找包含长 UA 的记录。
预期:
-
显示原始 UA 文本(不再映射为 VS Code/Cursor 等)。
-
文本可换行完整展示,不被
`...`
截断。
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment