Capture Neko/WG/network hubs, Studio viewer charts, physical deploy docs, and one-shot scripts so VPS vs physical can be toggled later without losing WIP. Co-authored-by: Cursor <cursoragent@cursor.com>
94 lines
4.0 KiB
Markdown
94 lines
4.0 KiB
Markdown
# 一键配置化安装(不依赖 AI)
|
||
|
||
两套生产形态共用同一套「填配置 → 跑脚本」流程。
|
||
|
||
| 形态 | 跑在哪 | 脚本 |
|
||
|------|--------|------|
|
||
| **VPS 本机** | 海外 VPS(应用 + Nginx/Caddy TLS **同机**) | `scripts/bootstrap_vps.sh` |
|
||
| **物理机应用** | 家里 Ubuntu / PVE 客户机(无公网证书) | `scripts/bootstrap_physical.sh` |
|
||
| **物理机边缘** | 海外 VPS(只写 Caddy → WG;应用不在这台) | `scripts/bootstrap_physical_edge.sh` |
|
||
|
||
国内第二边缘(宝塔 Nginx + `wg-dy-cn`)目前以 [PHYSICAL_DEPLOY.md](PHYSICAL_DEPLOY.md) 手工步骤为准,尚未并入 `install.sh` 菜单。
|
||
|
||
入口(交互菜单):
|
||
|
||
```bash
|
||
# 在目标 Linux 上(root),仓库已在当前目录或即将 clone
|
||
sudo bash scripts/install.sh
|
||
```
|
||
|
||
## 方式 A:交互向导(推荐)
|
||
|
||
```bash
|
||
sudo bash scripts/install.sh
|
||
# 1 = vps · 2 = physical · 3 = edge
|
||
# 按提示填写:域名、管理员账号/密码、Git URL、端口等
|
||
```
|
||
|
||
缺省必填项时,直接跑 `bootstrap_*.sh` 也会进入向导。
|
||
|
||
## 方式 B:环境文件(可重复、可自动化)
|
||
|
||
```bash
|
||
cp scripts/install.env.example /etc/douyinweb.install.env
|
||
chmod 600 /etc/douyinweb.install.env
|
||
# 编辑 DOMAIN / ADMIN_* / GIT_URL / INSTALL_SHAPE …
|
||
sudo bash scripts/install.sh
|
||
```
|
||
|
||
也可用环境变量一次性传入(适合 CI / Ansible):
|
||
|
||
```bash
|
||
INSTALL_SHAPE=vps \
|
||
DOMAIN=app.example.com \
|
||
ADMIN_USER=admin ADMIN_PASS='***' \
|
||
GIT_URL='https://git.example/you/douyinWEB.git' \
|
||
GIT_BRANCH=main FRESH=1 \
|
||
sudo -E bash scripts/install.sh
|
||
```
|
||
|
||
## 物理机完整顺序
|
||
|
||
1. **DNS**:`${DOMAIN}` A 记录 → **海外边缘 VPS**(不是家里公网 IP)。若要国内域名:`${DOMAIN_CN}` → **国内边缘**。
|
||
2. **WireGuard**:
|
||
- 必选:`wg-dy` 海外 `10.8.0.1` ↔ 物理 `10.8.0.2`,AllowedIPs **仅** `10.8.0.0/24`。
|
||
- 可选双边缘:`wg-dy-cn` 国内 `10.9.0.1` ↔ 物理 `10.9.0.2`(详见 [PHYSICAL_DEPLOY.md](PHYSICAL_DEPLOY.md) §3.2)。
|
||
3. **物理机**:`INSTALL_SHAPE=physical sudo bash scripts/install.sh`
|
||
- 监听 `0.0.0.0`
|
||
- **不**装本机证书
|
||
- 删除 `monitor.db`(新装零房间)
|
||
- 生成 `/root/douyinweb-${DOMAIN}.caddy` 草稿
|
||
4. **海外边缘**:`INSTALL_SHAPE=edge sudo bash scripts/install.sh`
|
||
- 只新增一个 Caddy site → `WG_UPSTREAM_IP:4015/8014`(通常 `10.8.0.2`)
|
||
- `systemctl reload caddy`(不要乱 restart 整机业务)
|
||
5. **国内边缘(可选)**:在已有 Nginx/宝塔上新增 `${DOMAIN_CN}` → `10.9.0.2`;WebRTC DNAT + 安全组;物理机 `DY_CORS_ORIGINS` 含两域名,`DY_NEKO_NAT1TO1` = 国内公网 IP 并 recreate Neko。
|
||
6. 验证:`curl https://${DOMAIN}/api/health`(及可选 `${DOMAIN_CN}`),并确认海外旧站仍 200。
|
||
|
||
> **不要用本节装纯 VPS。** 纯 VPS 选 `INSTALL_SHAPE=vps`,应用与 TLS 同机,无 WG 双边缘。
|
||
|
||
详细约束见 [PHYSICAL_DEPLOY.md](PHYSICAL_DEPLOY.md)。
|
||
|
||
## 配置项一览
|
||
|
||
见 [`scripts/install.env.example`](../scripts/install.env.example)。
|
||
|
||
运行时密钥写在 **`/etc/douyinweb.env`**(`SESSION_SECRET` 等,勿随意轮换,否则登录哈希失效)。
|
||
|
||
形态差异摘要见根目录 [README.md — 双形态对照](../README.md#双形态对照共用--纯-vps--物理机)。物理机出口 / Neko / Caddy 路径详见 [PHYSICAL_DEPLOY.md](PHYSICAL_DEPLOY.md)。
|
||
|
||
## 不要做的事
|
||
|
||
- 把带密码的 `install.env` / `_deploy_*.py` 提交进 Git
|
||
- 物理机 AllowedIPs 写 `0.0.0.0/0`(会抢 ShellCrash)
|
||
- 为修物理机去动 VPS 上已有 `dylive` / sing-box / 其它 Caddy 站
|
||
- 把纯 VPS 当物理机:在同机再搞一套 `wg-dy`「边缘」或假设有 ShellCrash `:7890`
|
||
- 把物理机当纯 VPS:在家里再申请公网证书、或把 `DY_PUBLIC_BASE_URL` 写成 `10.8.0.2`
|
||
- 打包或恢复别人的 `monitor.db`
|
||
|
||
## 与旧脚本关系
|
||
|
||
| 旧 | 新 |
|
||
|----|----|
|
||
| 只 `export` 再跑 `bootstrap_vps.sh` | 仍可用;缺变量会向导 |
|
||
| 一堆 `_deploy_*_physical.py`(AI 用) | 运维请用本目录 `install.sh` / `bootstrap_physical*.sh` |
|