028dc2c8b6
宝塔 API 走 :port/system,安全入口仅用于浏览器登录;修复代理 404。 Co-authored-by: Cursor <cursoragent@cursor.com>
28 lines
1.1 KiB
Markdown
28 lines
1.1 KiB
Markdown
# 2026-06-21 宝塔 bootstrap 写入正确 api.json 路径
|
|
|
|
## 摘要
|
|
|
|
SSH bootstrap 将 API 配置写入 `/www/server/panel/data/api.json`,而宝塔面板实际读取 `/www/server/panel/config/api.json`,导致白名单与 token 未生效,所有代理 API 返回「IP校验失败」。
|
|
|
|
## 动机
|
|
|
|
生产验收:8 台已 configured 服务器全部代理失败;子机 exec 显示 `config/api.json` 白名单仍为旧 IP `172.96.253.26`,与 `data/api.json` 不一致。
|
|
|
|
## 涉及文件
|
|
|
|
- `server/infrastructure/btpanel/client.py` — 签名 `md5(time+token)`
|
|
- `server/infrastructure/btpanel/ssh_bootstrap.py` — `base_url` 不含安全入口路径
|
|
- `tests/test_btpanel_ssh_bootstrap.py` — `exit_code=0` 回归用例(上一轮)
|
|
|
|
## 迁移 / 重启
|
|
|
|
- 需部署 API 后,对已 configured 服务器**重新执行 bootstrap**(手动或批量)以合并白名单与 token 到正确文件。
|
|
- 无需 DB 迁移。
|
|
|
|
## 验证
|
|
|
|
```bash
|
|
.venv/bin/pytest tests/test_btpanel_ssh_bootstrap.py -q
|
|
# 生产:POST /api/btpanel/servers/{id}/bootstrap 后 GET .../system/total 应返回真实指标而非 IP 错误
|
|
```
|