AnyBot/relay/Caddyfile.open

62 lines
2.1 KiB
Caddyfile
Raw Permalink Normal View History

傻瓜安裝:伺服器 sh AnyBot/install.sh server 再 make update-server 就好(自動裝 Docker、自己選網址——Tailscale 用 http、區網用自己的憑證、有 Tailscale 憑證用它的名字——自己產生邀請碼和所有金鑰,中間不問問題,沒有終端機也跑得完);不用先開帳號:大腦管理員(compose 的 brains,anybot --brains)看到有人用邀請碼註冊,就替那個帳號開一個雲端大腦 anybot-brain-帳號(自己的資料卷、帳號伺服器發的登入,伺服器不存密碼),停了叫醒、重開機回來;第一個註冊的是擁有者,只有它的大腦有伺服器上的 Docker(Bot 的電腦),其他人的大腦拿掉 NET_RAW、限記憶體、CPU、程序數,最多 20 個;更新後換成新版時新的先在舊的旁邊建好,Docker 拒絕的話舊的照常在跑,舊的確定停了才換、換不成放回舊的,管理員中途被停掉下次接回來,一直失敗的帳號隔 1、2、4…分鐘最多半小時再試。電腦登入有雲端大腦的伺服器時,先等它上線(最多約一分半)再當它的螢幕和手腳,不把自己當大腦。帳號伺服器只相信 Caddy(帶暗號)說的請求來源,大腦自己寫 X-Forwarded-For 繞不過註冊、登入的次數限制;舊的 Caddyfile 更新時自動補上那一行(舊版 mawk 也行),Caddy 檢查過才換上。 順手修:Anthropic 回「錯誤 400:Invalid signature in thinking block」時這一輪不再停下來:舊的思考內容對不上就請它丟掉(thinking-binding-controls)或拿掉重送,聊天紀錄裡也一起丟掉,之後不再撞到;手機帳號登入的一個偶發失敗的測試。 功能地圖新增 server 區(models 和地圖的 README 跟著改),FEATURES、README.md、docs/multi-device.md 也改了;計畫在 docs/plan-2026-11-install.md(S8 App 信任伺服器的憑證、S9 伺服器上裝手腳還沒做)。 已驗證: cargo test(902)、relay cargo test(29)、bash -n;在 nobledesktop 上的隔離測試機(Ubuntu 24.04、全新安裝):一般使用者 install.sh server+make update-server 不給任何設定就跑完、兩個帳號註冊後各自有雲端大腦且在線、只有擁有者的大腦連得到 Docker、偽造 X-Forwarded-For 被擋、ANYBOT_BRAINS_SKIP 停掉指定帳號、重開機後全部回來、舊版伺服器(有自己的大腦)更新後保留原本的大腦並補上 Caddyfile、程式更新只換一次、只改 .env 不換、Docker 拒絕建立時舊的照常在跑、這次的更新(大腦管理員就緒、amy 換成新版在線、沒有殘留);Debian 10 的 mawk 1.3.3 補 Caddyfile;Anthropic 真的帳號:舊思考內容對不上時這一輪照常回答、丟掉的有回報;七輪獨立審查,最後兩輪沒有 P0/P1。 未驗證: 公開網址(有網域、DNS)那條路(要真的網域);Mac App 用帳號登入後等雲端大腦再當螢幕只跑了測試(ignored 的實機測試要真的伺服器);更新中途按 Ctrl-C 把管理員開回來只讀過程式沒實際按。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha2uBHmbnuWBhNzjbJm
2026-11-23 00:09:02 +00:00
# This server's own address on a tailnet (headscale, or Tailscale without its certificates) or in
# the local network, set up the easy way (setup.sh with no questions): AnyBot and the phone just
# open http://ADDR — nothing to trust first. On a tailnet the line is already encrypted
# (WireGuard). setup.sh writes this with ADDR replaced by the address.
#
# https://ADDR is here too, with a certificate Caddy signs itself (its own small authority, kept
# in the caddy-data volume): the phone's notifications need https. Trust it once on that phone:
# open http://ADDR/anybot-ca.crt and install it (iPhone: then 設定 › 一般 › 關於本機 › 憑證信任設定).
{
# A browser asking for an IP address doesn't say which name it wants (no SNI).
default_sni ADDR
# The authority lives in this container only; nothing is installed on the server itself.
skip_install_trust
# http is served, not sent on to https.
auto_https disable_redirects
}
(anybot) {
encode gzip
header {
X-Content-Type-Options "nosniff"
X-Frame-Options "SAMEORIGIN"
Referrer-Policy "no-referrer"
}
request_body {
max_size 210MB
}
# The 大腦管理員 API is for this server's own manager, inside (deploy/server: brains).
respond /relay/manager/* 404
reverse_proxy relay:8080 {
# Who asked, believed only from here (ANYBOT_PROXY_SECRET in .env; a cloud brain
# talking to the account server straight can't send it).
header_up X-AnyBot-Proxy {$ANYBOT_PROXY_SECRET}
# The phone's "anything new?" request waits up to 35 s. Each AnyBot also keeps one
# WebSocket open here (pinged every 15–20 s, so it never sits idle for 60 s).
transport http {
read_timeout 620s
}
# Reloading this file doesn't cut those connections at once.
stream_close_delay 5m
}
}
https://ADDR {
tls internal
import anybot
}
# Any name or address that reaches this server on port 80 (the tailnet's name for it, another
# address of it): the same account server, not a blank page.
http:// {
handle /anybot-ca.crt {
root * /data/caddy/pki/authorities/local
rewrite * /root.crt
header Content-Type application/x-x509-ca-cert
file_server
}
handle {
import anybot
}
}