62 lines
2.1 KiB
Caddyfile
62 lines
2.1 KiB
Caddyfile
|
|
# 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
|
|||
|
|
}
|
|||
|
|
}
|