From d3840ee73bb52af135e68ac155bde0a0194d9815 Mon Sep 17 00:00:00 2001 From: eric Date: Sat, 8 Aug 2026 10:11:57 -0500 Subject: [PATCH] Document dylive.nomadro.com Caddy routes and SeaweedFS feiniu/s3 hosts. Co-authored-by: Cursor --- README.md | 11 ++++ scripts/setup_caddy_dylive.py | 103 ++++++++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 scripts/setup_caddy_dylive.py diff --git a/README.md b/README.md index a5db811..9e78fc4 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,17 @@ python scripts\sync_cookie_and_probe.py 前缀 `DY_`,见 `backend/app/config.py`(如 `DY_PB_URL`、`DY_OFFLINE_INTERVAL_SEC`)。 +## 线上地址 + +| 用途 | URL | +|------|-----| +| 控制台 | https://dylive.nomadro.com/ | +| API | https://dylive.nomadro.com/api/health | +| PocketBase | https://dylive.nomadro.com/_/ | +| SeaweedFS S3 | https://feiniu.nomadro.com/ (别名 https://s3.nomadro.com/) | + +反代由本机 **Caddy** 自动 HTTPS;后端进程:`4015` Next / `8014` API / `8092` PB / `8333` SeaweedFS S3。 + ## 说明 - 为方便部署同步,仓库包含 `backend/data/`(SQLite、封面、Cookie 设置)与 `pb/pb_data/`。 diff --git a/scripts/setup_caddy_dylive.py b/scripts/setup_caddy_dylive.py new file mode 100644 index 0000000..b894a1b --- /dev/null +++ b/scripts/setup_caddy_dylive.py @@ -0,0 +1,103 @@ +# -*- coding: utf-8 -*- +"""Configure Caddy for dylive + feiniu/s3 SeaweedFS.""" +import paramiko + +HOST = "107.173.30.245" +c = paramiko.SSHClient() +c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) +c.connect(HOST, 22, "root", "Xiao4669805", timeout=30, allow_agent=False, look_for_keys=False) + +cmd = r""" +set -e + +cp -a /etc/caddy/Caddyfile /etc/caddy/Caddyfile.bak.$(date +%Y%m%d%H%M%S) + +# Douyin live monitor +cat >/etc/caddy/sites/dylive.nomadro.com.caddy <<'EOF' +# DouyinWEB — Next.js + FastAPI + PocketBase +# https://dylive.nomadro.com + +dylive.nomadro.com { + encode gzip + + handle /api/* { + reverse_proxy 127.0.0.1:8014 + } + + handle /covers/* { + reverse_proxy 127.0.0.1:8014 + } + + # PocketBase admin / API mirror + handle /_/* { + reverse_proxy 127.0.0.1:8092 + } + + handle { + reverse_proxy 127.0.0.1:4015 + } +} +EOF + +# SeaweedFS S3 (开源带 F:飞牛 feiniu) +cat >/etc/caddy/sites/feiniu.nomadro.com.caddy <<'EOF' +# SeaweedFS S3 API +# https://feiniu.nomadro.com + +feiniu.nomadro.com { + encode gzip + request_body { + max_size 200MB + } + reverse_proxy 127.0.0.1:8333 +} +EOF + +cat >/etc/caddy/sites/s3.nomadro.com.caddy <<'EOF' +# SeaweedFS S3 API (alias) +# https://s3.nomadro.com + +s3.nomadro.com { + encode gzip + request_body { + max_size 200MB + } + reverse_proxy 127.0.0.1:8333 +} +EOF + +# validate + reload +caddy validate --config /etc/caddy/Caddyfile +systemctl reload caddy +sleep 2 +systemctl is-active caddy + +# update API public S3 base to feiniu HTTPS +sed -i 's|Environment=DY_S3_PUBLIC_BASE=.*|Environment=DY_S3_PUBLIC_BASE=https://feiniu.nomadro.com|' /etc/systemd/system/douyinweb-api.service +grep DY_S3_PUBLIC /etc/systemd/system/douyinweb-api.service +systemctl daemon-reload +systemctl restart douyinweb-api +sleep 4 + +echo '--- https checks ---' +curl -sI --max-time 20 https://dylive.nomadro.com/ | head -15 +echo +curl -s -o /dev/null -w 'dylive:%{http_code}\n' --max-time 20 https://dylive.nomadro.com/ +curl -s -o /dev/null -w 'dylive_api:%{http_code}\n' --max-time 20 https://dylive.nomadro.com/api/health +curl -s --max-time 20 https://dylive.nomadro.com/api/health | head -c 250 +echo +curl -s -o /dev/null -w 'feiniu:%{http_code}\n' --max-time 15 https://feiniu.nomadro.com/ +curl -s -o /dev/null -w 's3:%{http_code}\n' --max-time 15 https://s3.nomadro.com/ + +SID=$(curl -s https://dylive.nomadro.com/api/sessions/active | python3 -c "import sys,json; d=json.load(sys.stdin); ss=d.get('sessions') or []; print(next((x['id'] for x in ss if x.get('cover_url')), ''))") +echo SID=$SID +if [ -n "$SID" ]; then + curl -s -o /dev/null -w 'cover:%{http_code} size:%{size_download}\n' --max-time 20 "https://dylive.nomadro.com/api/sessions/$SID/cover" +fi +""" +_, o, _ = c.exec_command(cmd, timeout=180, get_pty=True) +print(o.read().decode("utf-8", errors="replace")[-6000:]) +c.close() +print("\nhttps://dylive.nomadro.com/") +print("https://feiniu.nomadro.com/ (SeaweedFS S3)") +print("https://s3.nomadro.com/ (S3 alias)")