docs(ops): record remote runtime inventory
Some checks failed
CI / test (push) Has been cancelled
CI / frontend (push) Has been cancelled
CI / golangci-lint (push) Has been cancelled
Security Scan / backend-security (push) Has been cancelled
Security Scan / frontend-security (push) Has been cancelled

This commit is contained in:
zizi 2026-06-05 17:06:25 +08:00
parent 63b9c880b5
commit ebf4d8c3c3
11 changed files with 402 additions and 0 deletions

View File

@ -12,6 +12,7 @@ ops/remote/<provider-or-region>-<host-date>-sub2api/
|------|---------------|----------|------|
| `jppro-sub2api/` | `个人-JPpro-akile-0504-1c1g` | `https://proxy.api.lilifamily.com` / `https://jp.proxy.api.lilifamily.com` | proxy-ng 公开入口节点,回源到 3c4g origin |
| `us-racknerd-0425-sub2api/` | `个人-US-racknerd-0425-1c1g` | `https://pai.cyan2000.uk` | 旧机,迁移来源和回滚来源 |
| `us-racknerd-0518-6c6g/` | `个人-US-racknerd-0518-6c6g` | `107.173.34.139:3389` | 远程桌面 / 浏览器运行环境XRDP 运行中,暂无 Sub2API 部署记录 |
| `us-racknerd-0526-sub2api/` | `个人-US-racknerd-0526-3c4g` | `https://origin.proxy.api.lilifamily.com` / `https://catproxy.lilifamily.com` | Sub2API 受限 origin 和公开直连主站入口 |
## 留痕规则

View File

@ -0,0 +1,17 @@
secrets/*
!secrets/README.md
backups/*
!backups/.gitkeep
*.env
*.key
*.pem
*.crt
*.p12
*.tar
*.tar.gz
*.zip
*.sql
*.dump
*.bak
*.backup

View File

@ -0,0 +1,230 @@
# US RackNerd 0518 6c6g Remote Inventory
最后核对时间2026-06-04 10:13 Asia/Shanghai
## 远程位置
- Tabby profile`个人-US-racknerd-0518-6c6g`
- Hostname`racknerd-64b35ec`
- 公网 IP`107.173.34.139`
- 系统Ubuntu 24.04 LTS
- 当前用途:远程桌面 / 浏览器运行环境
- Sub2API 状态:本次只读检查未发现 Docker 容器运行,也未发现 `/opt/sub2api` Compose 部署。
## 当前状态
- `xrdp`active公网监听 `*:3389`
- `xrdp-sesman`active仅监听本机 `::1:3350`
- `xrdp` 用户已加入 `ssl-cert` 组,可读取 `/etc/xrdp/key.pem` 指向的 snakeoil 私钥。
- 旧的 root XRDP 图形会话 `:10` 已清理;`/tmp/.X11-unix/` 下不再存在 `X10``X11`
- 当前仅保留 `X99`,对应已有的 `Xvfb :99` 虚拟显示。
- 指纹浏览器配置目录:`/opt/fingerprint-browser`
- 指纹浏览器配置文件:`/opt/fingerprint-browser/profiles.json`
- 指纹 `fp-us-01``fp-us-10` 当前使用本机代理 `http://127.0.0.1:10021`,时区 `America/Los_Angeles`
- 指纹 `fp-us-11``fp-us-30` 当前使用本机代理 `http://127.0.0.1:10020`,时区 `America/Los_Angeles`
- 代理21 已新增为本机中继 `http://127.0.0.1:10021`,上游 `154.61.160.78:443`;认证凭据只保存在远程,不写入 Git。
- UFWinactive`3389` 仍公网开放。
## 远程控制故障记录
### 2026-06-04 XRDP 登录后远程控制失败
现象:
- 用户反馈远程控制失败。
- Tabby SSH 可连接 6c6g 主机,说明 SSH 链路正常。
- XRDP 端口 `3389` 可监听,但最近 XRDP 登录后图形窗口管理器快速退出。
已验证事实:
- `xrdp``xrdp-sesman` 均为 running。
- 认证成功后,`xrdp-sesman` 曾创建 root 图形会话 `:11`
- `/var/log/xrdp-sesman.log` 显示 `Window manager ... exited quickly (1 secs)`
- 机器上残留一个 2026-05-29 启动的 root XRDP 图形会话 `:10`
- `xrdp` 用户原先不在 `ssl-cert` 组,导致读取 `/etc/xrdp/key.pem``Permission denied`
执行的最小修复:
```bash
usermod -aG ssl-cert xrdp
systemctl restart xrdp
loginctl terminate-session c5
systemctl restart xrdp-sesman
```
实际执行中,清理旧 root 图形会话后当前 Tabby SSH 面板断开;随后使用新的 Tabby SSH 会话重新连接并完成验证。
验证结果:
```bash
id xrdp
systemctl is-active xrdp xrdp-sesman
ss -lntp | grep -E ':(3389|3350)\b'
ps -eo pid,ppid,user,stat,lstart,cmd | grep -E 'xrdp|Xorg :10|Xorg :11|xfce4-session'
loginctl list-sessions --no-legend
ls -la /tmp/.X11-unix
journalctl -u xrdp -u xrdp-sesman --since '10 minutes ago' --no-pager
```
关键输出摘要:
- `id xrdp``groups=113(xrdp),111(ssl-cert)`
- `systemctl is-active xrdp xrdp-sesman`:均返回 `active`
- `ss -lntp``*:3389``::1:3350` 正常监听
- 残留 GUI 进程:仅剩 `xrdp``xrdp-sesman`,未见 `Xorg :10``Xorg :11``xfce4-session`
- `/tmp/.X11-unix`:仅剩 `X99`
- 新日志中不再出现 `Cannot read private key file ... Permission denied`
## 剩余风险
- `3389` 仍公网开放,且日志中有多次非本人来源 IP 的 RDP 探测或连接失败记录。
- 建议后续将 `3389` 限制到可信来源 IP或改为 SSH 隧道 / VPN 后访问 XRDP。
- 本次未做防火墙收紧,因为用户只确认执行证书权限修复和旧会话清理。
### 2026-06-04 指纹 4-30 代理与地址调整
目标:
- 将 `fp-us-04``fp-us-30` 的代理统一改为“代理20”。
- 将指纹地址与代理20一致即圣何塞当前系统无单独城市/经纬度字段,使用 `timezone=America/Los_Angeles` 表达地址一致性。
已验证事实:
- 指纹配置源是 `/opt/fingerprint-browser/profiles.json`
- `fp-manager` 启动浏览器时读取 `profiles.json``proxy``timezone``lang``accept_lang` 等字段。
- 代理20对应 `http://127.0.0.1:10020`
- `127.0.0.1:10020` 当前由 `gost` 监听,上游代理信息只保存在远程进程/配置中,不写入 Git。
- `profiles.json` schema 未发现独立城市、经纬度或地址字段。
执行的最小修改:
```text
fp-us-04 ... fp-us-30:
proxy = http://127.0.0.1:10020
timezone = America/Los_Angeles
```
备份:
```text
/opt/fingerprint-browser/backups/profiles-before-proxy20-san-jose-20260604-082428.json
sha256: a7833f4862b68f7c6e309ad4f3264e9b1594da2a17396ccf481edfece7991147
```
验证结果:
- `fp-us-04``fp-us-30` 均存在。
- `fp-us-04``fp-us-30``proxy` 均为 `http://127.0.0.1:10020`
- `fp-us-04``fp-us-30``timezone` 均为 `America/Los_Angeles`
- 校验脚本输出 `bad_count 0`
- `ss -lntp` 显示 `127.0.0.1:10020` 正在监听。
### 2026-06-05 新增代理21并核对前30指纹一致性
目标:
- 新增代理21`154.61.160.78:443`,用户名和密码只保存在远程。
- 核对前 30 个指纹和对应代理的位置时区是否一致。
远程变更:
- 更新 `/opt/fingerprint-browser/proxy-relay.json`,新增 `listen_port=10021`
- 启动 `gost` 本机中继:`127.0.0.1:10021 -> 154.61.160.78:443`
- 未修改 `profiles.json` 中任何指纹的代理或时区字段。
备份:
```text
/opt/fingerprint-browser/backups/proxy-relay-before-proxy21-20260605-042450.json
sha256: 4d7f43734aa7b2b9871dd969980ed1c382c500b0555371ae52e39e8a1a8c91f3
```
统一前验证结果:
- `ss -lntp` 显示 `127.0.0.1:10021` 正在由 `gost` 监听。
- `proxy-relay.json` 中已有 `listen_port=10021`,上游为 `154.61.160.78:443`,凭据未写入本仓库。
- 前 30 个指纹统一前代理分布:`10001` 1 个,`10002` 1 个,`10003` 1 个,`10020` 27 个。
- 前 30 个指纹统一前时区分布:`America/Los_Angeles` 28 个,`America/New_York` 1 个,`America/Chicago` 1 个。
- `ping0.cc` 通过代理访问时可确认出口 IP`10020 -> 154.61.160.70``10021 -> 154.61.160.78`;命令行 `curl` 形态只返回出口 IP未返回城市字段。
- 位置判断口径以 `ping0.cc` 看到的网络出口地址为准,不以公开 IP 归属库或注册地为准。
- 若按网络出口地址为 California / San Jose则对应时区应为 `America/Los_Angeles`
统一前配置一致性摘要:
| 指纹范围 | 当前代理 | 当前时区 | San Jose 口径下状态 |
|---|---|---|---|
| `fp-us-01` | `10001` | `America/New_York` | 时区不一致 |
| `fp-us-02` | `10002` | `America/Chicago` | 时区不一致 |
| `fp-us-03` | `10003` | `America/Los_Angeles` | 时区一致,代理出口位置仍需按 ping0.cc 单独核对 |
| `fp-us-04``fp-us-30` | `10020` | `America/Los_Angeles` | 与 San Jose 时区一致 |
风险说明:
- 2026-06-04 曾按当时认知把代理20视为圣何塞并将 `fp-us-04``fp-us-30` 设置为 `America/Los_Angeles`
- 2026-06-05 早期核对曾误用公开 IP 地理库将代理20 和代理21 判断为 London / `Europe/London`;该结果反映的是 IP 库归属口径,不作为本次“网络出口地址”判断依据。
- 前 30 个指纹后续已按下面记录统一到代理20 和 `America/Los_Angeles`
### 2026-06-05 前30指纹统一到代理20和 San Jose 时区
目标:
- 将 `fp-us-01``fp-us-30` 全部统一到代理20。
- 将 `fp-us-01``fp-us-30` 全部统一为 San Jose 对应时区 `America/Los_Angeles`
- 保持语言配置为 `en-US``en-US,en;q=0.9`
远程变更:
- 修改 `/opt/fingerprint-browser/profiles.json`
- `fp-us-01``fp-us-30``proxy` 均为 `http://127.0.0.1:10020`
- `fp-us-01``fp-us-30``timezone` 均为 `America/Los_Angeles`
- 实际发生字段变化的指纹为 `fp-us-01``fp-us-02``fp-us-03``fp-us-04``fp-us-30` 在本次操作前已经符合目标配置。
- 清理了本次排查过程中残留的 `fp-us-04` 前台 Chromium 进程。
备份:
```text
/opt/fingerprint-browser/backups/profiles-before-first30-proxy20-sanjose-20260605-044622.json
sha256: 0cde07a9fe021b42a44b9f6ebf978da761945651c6fdf7c02c95ad235fa42a7c
```
验证结果:
- 前 30 个指纹数量:`30`
- 前 30 个指纹代理分布:`http://127.0.0.1:10020` 30 个。
- 前 30 个指纹时区分布:`America/Los_Angeles` 30 个。
- 前 30 个指纹语言分布:`en-US` 30 个。
- 前 30 个指纹 `accept_lang` 分布:`en-US,en;q=0.9` 30 个。
- 修改后 `/opt/fingerprint-browser/profiles.json` sha256`da4c86069e1d4d277c55d15a269df62e3fda9c692f301cb4f097c151fa2a40b4`
- `ping0.cc` 通过代理20 返回出口 IP`154.61.160.70`
### 2026-06-05 指纹1-10切换到代理21
目标:
- 将 `fp-us-01``fp-us-10` 的代理切换为代理21。
- 保持 `fp-us-01``fp-us-30` 的时区为 San Jose 对应时区 `America/Los_Angeles`
- 保持语言配置为 `en-US``en-US,en;q=0.9`
远程变更:
- 修改 `/opt/fingerprint-browser/profiles.json`
- `fp-us-01``fp-us-10``proxy``http://127.0.0.1:10020` 改为 `http://127.0.0.1:10021`
- `fp-us-11``fp-us-30` 继续使用 `http://127.0.0.1:10020`
- 未修改时区、语言和其他指纹字段。
备份:
```text
/opt/fingerprint-browser/backups/profiles-before-fp01-10-proxy21-20260605-062320.json
sha256: da4c86069e1d4d277c55d15a269df62e3fda9c692f301cb4f097c151fa2a40b4
```
验证结果:
- 前 30 个指纹数量:`30`
- `fp-us-01``fp-us-10` 代理分布:`http://127.0.0.1:10021` 10 个。
- `fp-us-11``fp-us-30` 代理分布:`http://127.0.0.1:10020` 20 个。
- 前 30 个指纹时区分布:`America/Los_Angeles` 30 个。
- 修改后 `/opt/fingerprint-browser/profiles.json` sha256`ed309ea1302948a7b02c49dd2660b13976ba1a2fa1d4567af884cf3254b41ada`
- `ping0.cc` 通过代理20 返回出口 IP`154.61.160.70`
- `ping0.cc` 通过代理21 返回出口 IP`154.61.160.78`

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,8 @@
# Current Runtime Notes
本目录记录 `个人-US-racknerd-0518-6c6g` 当前远程控制相关的非敏感状态。
- 2026-06-04修复 `xrdp` 读取 TLS 私钥的组权限。
- 2026-06-04清理 root 旧 XRDP 图形会话 `:10`
- 当前未保存 `/etc/xrdp/key.pem` 或证书私钥副本;证书私钥不得提交。

View File

@ -0,0 +1,7 @@
# Planned Changes
待确认后再执行:
- 将公网 `3389` 限制到可信来源 IP。
- 或改用 SSH 隧道 / VPN 后访问 XRDP避免公网裸露远程桌面端口。

View File

@ -0,0 +1,10 @@
# Secrets Directory
本目录只允许本机私有保存敏感材料,例如:
- XRDP 私钥或证书备份
- 远程桌面登录凭据
- 临时备份包
真实敏感文件禁止提交 Git已由本目录 `.gitignore` 排除。

View File

@ -23,6 +23,7 @@
- `proxy.api.lilifamily.com` 已切到 JPpro `151.242.164.72`3c4g 上旧 `proxy.api` nginx 站点已禁用。
- Sub2API 只绑定宿主机 `127.0.0.1:8080`,公网只能经 nginx `catproxy` 或受限 `origin` 转发。
- PostgreSQL、Redis、Mihomo 不映射公网端口。
- CLIProxyAPI 已部署为同机内网服务,容器加入 `sub2api-network`,宿主机仅监听 `127.0.0.1:8317`
- 从旧机迁移的业务计数已核对:`users=1``api_keys=3``accounts=133`
## 本地留痕
@ -33,6 +34,8 @@
- 当前 catproxy 配置副本:`current/nginx-catproxy-sub2api.conf`
- 当前默认拒绝配置副本:`current/nginx-default-deny.conf`
- 当前 token map 配置副本:`current/proxy-ng-token-map.conf`,真实 token 已脱敏
- 当前 CLIProxyAPI Compose 副本:`current/cliproxyapi-compose.yml`
- 当前 CLIProxyAPI 配置副本:`current/cliproxyapi-config.redacted.yaml`,业务调用密钥已脱敏
- 防火墙与 origin 边界记录:`current/firewall-notes.md`
- 迁移包 SHA256 记录:`backups/migrate-to-racknerd-0526-20260525-205103.SHA256SUMS`
- 密钥目录说明:`secrets/README.md`
@ -53,6 +56,16 @@ sub2api container
postgres / redis / mihomo containers
```
Sub2API 调用 CLIProxyAPI 的同机内网路径:
```text
sub2api container
↓ Docker DNS: http://cli-proxy-api:8317
cli-proxy-api container
↓ OAuth auths / configured upstream API keys
upstream model providers
```
公开直连主站路径:
```text
@ -69,6 +82,7 @@ Sub2API
- `catproxy.lilifamily.com` 不做 IP 白名单限制,是 3c4g 上可直接访问的主站域名和回滚入口。
- `proxy.api.lilifamily.com` 不再解析到 3c4g也不再由 3c4g nginx 站点提供服务。
- Sub2API 容器端口只绑定 `127.0.0.1:8080`
- CLIProxyAPI 不接入 nginx不配置公网域名公网不可直接访问 `8317`
## 当前配置要点
@ -82,6 +96,12 @@ Sub2API
- 远程 `.env``PUBLIC_DOMAIN=proxy.api.lilifamily.com`
- 远程 `.env``SUB2API_IMAGE=sub2api:custom-menu-safe-embed-20260527-r2`
- URL allowlist 当前关闭:`SECURITY_URL_ALLOWLIST_ENABLED=false`
- 远程 `.env``SECURITY_URL_ALLOWLIST_ALLOW_INSECURE_HTTP=true`,允许 APIKey 上游 base_url 使用 `http://`
- CLIProxyAPI 部署目录:`/opt/cliproxyapi`
- CLIProxyAPI 镜像:`eceasy/cli-proxy-api:v7.1.39`
- CLIProxyAPI 宿主机监听:`127.0.0.1:8317`
- CLIProxyAPI Docker 网络地址:`http://cli-proxy-api:8317`
- CLIProxyAPI 业务调用密钥:远程 `/opt/cliproxyapi/secrets/generated-credentials.txt`,不提交 Git。
## DNS state after proxy-ng hardening
@ -104,6 +124,15 @@ curl --noproxy '*' -i https://origin.proxy.api.lilifamily.com/health
curl --noproxy '*' -i https://catproxy.lilifamily.com/health
```
CLIProxyAPI 内网检查:
```bash
cd /opt/cliproxyapi
docker compose ps
curl --noproxy '*' -sS http://127.0.0.1:8317/healthz
docker exec sub2api sh -lc 'wget -q -S -O - http://cli-proxy-api:8317/healthz 2>&1 | sed -n "1,12p"'
```
期望结果:
- `sub2api``sub2api-postgres``sub2api-redis` 为 healthy。
@ -112,6 +141,8 @@ curl --noproxy '*' -i https://catproxy.lilifamily.com/health
- JPpro 带 `X-Proxy-Ng-Token` 访问 origin 返回 `200`
- 公网访问 `catproxy.lilifamily.com/health` 返回 `200`
- 直连 `216.45.59.243:8080` 不对公网开放。
- `ss -ltnp` 显示 CLIProxyAPI 只监听 `127.0.0.1:8317`
- Sub2API 容器内访问 `http://cli-proxy-api:8317/healthz` 返回 `{"status":"ok"}`
## 操作记录
@ -215,3 +246,24 @@ curl --noproxy '*' -i https://catproxy.lilifamily.com/health
- 公网验证:`catproxy.lilifamily.com/health``proxy.api.lilifamily.com/health` 返回 `{"status":"ok"}`
- 菜单验证:`proxy.api.lilifamily.com/api/v1/settings/public` 返回版本 `0.1.131``custom_menu_items[0].label=购买套餐``omit_auth_context=true`
- iframe CSP 验证:`catproxy.lilifamily.com/custom/shop``proxy.api.lilifamily.com/custom/shop` 返回 `200`CSP `frame-src` 包含 `https://pay.ldxp.cn`
### 2026-06-02 允许 HTTP APIKey 上游
- 背景APIKey 账号测试 `http://` base URL 时返回 `Invalid base URL: invalid url scheme: http`
- 远程配置:`/opt/sub2api/.env` 第 58 行改为 `SECURITY_URL_ALLOWLIST_ALLOW_INSECURE_HTTP=true`
- 生效方式:`docker compose up -d --no-deps --force-recreate sub2api`,未重建镜像,未重启 PostgreSQL、Redis、Mihomo。
- 验证结果:`sub2api` 容器重建后为 `healthy`;容器内 `SECURITY_URL_ALLOWLIST_ALLOW_INSECURE_HTTP=true`;本机 `http://127.0.0.1:8080/health` 返回 `{"status":"ok"}`
- 安全注意:该配置允许配置 `http://` 上游,公网 HTTP 会明文传输上游 API Key优先只用于可信内网或明确接受风险的上游。
### 2026-06-02 CLIProxyAPI 内网部署
- 目标:在 3c4g 上部署 CLIProxyAPI仅供同机 Sub2API 调用,不开放公网入口。
- 部署目录:`/opt/cliproxyapi`
- 镜像:`eceasy/cli-proxy-api:v7.1.39`
- 容器:`cli-proxy-api`
- Docker 网络:加入现有 `sub2api-network`,网络别名 `cli-proxy-api`
- 监听边界:宿主机只绑定 `127.0.0.1:8317`,未配置 nginx 站点,未新增公网域名。
- 远程密钥:`/opt/cliproxyapi/secrets/cliproxyapi.env` 保存 `MANAGEMENT_PASSWORD``/opt/cliproxyapi/secrets/generated-credentials.txt` 保存 Sub2API 业务调用 key。
- 脱敏配置副本:`current/cliproxyapi-compose.yml``current/cliproxyapi-config.redacted.yaml`
- 验证结果:`curl http://127.0.0.1:8317/healthz` 返回 `200`;无业务 key 请求 `/v1/models` 返回 `401 Missing API key`;带业务 key 请求 `/v1/models` 返回 `200 {"data":[],"object":"list"}``docker exec sub2api` 内访问 `http://cli-proxy-api:8317/healthz` 返回 `200`
- 当前限制:尚未导入 OAuth auth 文件或上游 API key因此 `/v1/models` 返回空列表;后续需要为 CLIProxyAPI 配置具体 provider 后Sub2API 才能通过该内网地址调用上游模型。

View File

@ -0,0 +1,23 @@
services:
cli-proxy-api:
image: eceasy/cli-proxy-api:v7.1.39
container_name: cli-proxy-api
env_file:
- ./secrets/cliproxyapi.env
environment:
TZ: Asia/Shanghai
ports:
- "127.0.0.1:8317:8317"
volumes:
- ./config.yaml:/CLIProxyAPI/config.yaml:ro
- ./auths:/root/.cli-proxy-api
- ./logs:/CLIProxyAPI/logs
networks:
sub2api-network:
aliases:
- cli-proxy-api
restart: unless-stopped
networks:
sub2api-network:
external: true

View File

@ -0,0 +1,51 @@
host: ""
port: 8317
tls:
enable: false
cert: ""
key: ""
remote-management:
allow-remote: false
secret-key: ""
disable-control-panel: true
disable-auto-update-panel: true
panel-github-repository: "https://github.com/router-for-me/Cli-Proxy-API-Management-Center"
auth-dir: "~/.cli-proxy-api"
api-keys:
- "<redacted-sub2-call-key>"
debug: false
pprof:
enable: false
addr: "127.0.0.1:8316"
commercial-mode: false
logging-to-file: true
logs-max-total-size-mb: 512
error-logs-max-files: 20
usage-statistics-enabled: false
redis-usage-queue-retention-seconds: 60
proxy-url: ""
force-model-prefix: false
passthrough-headers: false
request-retry: 3
max-retry-credentials: 0
max-retry-interval: 30
disable-cooling: false
disable-image-generation: false
quota-exceeded:
switch-project: true
switch-preview-model: true
antigravity-credits: true
routing:
strategy: "round-robin"
session-affinity: false
session-affinity-ttl: "1h"
codex:
identity-confuse: false
ws-auth: true
enable-gemini-cli-endpoint: false
nonstream-keepalive-interval: 0

View File

@ -4,5 +4,7 @@
- 目标远程 `.env` 路径:`/opt/sub2api/.env`
- 目标远程 Mihomo 配置路径:`/opt/sub2api/mihomo/config.yaml`
- CLIProxyAPI 远程密钥路径:`/opt/cliproxyapi/secrets/cliproxyapi.env`
- CLIProxyAPI 业务调用密钥记录:`/opt/cliproxyapi/secrets/generated-credentials.txt`
- 这些文件包含数据库密码、JWT 密钥、TOTP 密钥、订阅地址或代理凭据,默认被上级 `.gitignore` 排除。
- 不要提交真实密钥,不要把密钥写入 README、issue 或 PR。