Files
cpi-openai/部署.md
2026-03-18 15:06:25 +08:00

124 lines
2.4 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# CLIProxyAPI 部署指南
## 环境要求
- Linux 服务器(推荐 Ubuntu/Debian
- Docker + Docker Compose
- Git
## 1. 安装 Docker
```bash
curl -fsSL https://get.docker.com | sh
```
## 2. 拉取项目
```bash
cd /opt
git clone https://git.586vip.cn/huangzhenpc/cpi-openai.git cliproxyapi
cd cliproxyapi
```
## 3. 创建配置文件
```bash
cat > config.yaml << 'EOF'
host: ""
port: 8317
auth-dir: "/root/.cli-proxy-api"
api-keys:
- "TnUJWOC9im2eOMuxjoOVT1rLMGgmoL0"
remote-management:
allow-remote: true
secret-key: "OkrK7DRA06hVpRdfZyMD"
disable-control-panel: false
debug: false
request-retry: 3
routing:
strategy: "round-robin"
quota-exceeded:
switch-project: true
switch-preview-model: true
EOF
```
> 完整配置参考 `config.example.yaml`,按需添加 Claude/Gemini/Codex 等 Provider 的 API Key 或 OAuth 配置。
## 4. 启动服务
```bash
mkdir -p auths logs
docker compose up -d
```
## 5. 验证
```bash
# 查看日志
docker logs cli-proxy-api --tail 20
# 测试接口
curl http://localhost:8317/v1/models \
-H "Authorization: Bearer TnUJWOC9im2eOMuxjoOVT1rLMGgmoL0"
```
## 当前部署配置
| 项目 | 值 |
|------|------|
| API 地址 | `http://服务器IP:8317` |
| 客户端密钥 | `TnUJWOC9im2eOMuxjoOVT1rLMGgmoL0` |
| 管理面板 | `http://服务器IP:8317/management.html` |
| 管理密码 | `OkrK7DRA06hVpRdfZyMD` |
> 服务启动后,可通过管理面板在 Web 界面添加 Claude/Gemini 等 Provider 的 API Key无需再改配置文件。
## 端口说明
| 端口 | 用途 |
|------|------|
| 8317 | 主 API 服务 |
| 8085 | 管理面板 |
如需 OAuth 登录回调,额外开放:
| 端口 | 用途 |
|------|------|
| 54545 | Claude OAuth 回调 |
| 51121 | Codex OAuth 回调 |
| 1455 | Gemini OAuth 回调 |
| 11451 | 其他 OAuth 回调 |
## 常用运维命令
```bash
# 查看状态
docker ps
# 查看日志
docker logs -f cli-proxy-api
# 重启服务
docker compose restart
# 更新(拉取最新代码 + 重启)
git pull && docker compose pull && docker compose up -d
# 停止服务
docker compose down
```
## 生产环境建议
1. **HTTPS**:前置 Nginx 反代,配合 Let's Encrypt 证书
2. **防火墙**仅开放必要端口8317管理端口限制来源 IP
3. **管理密码**:务必设置 `remote-management.secret-key`
4. **日志**:开启 `logging-to-file: true` 并设置 `logs-max-total-size-mb` 限制磁盘占用