配置项
配置装配顺序为 默认值 ← 配置文件 ← 环境变量:先取内置默认,再用 TOML 配置文件覆盖,最后用 GATHER_* 环境变量覆盖。
- 配置文件:TOML,路径由
--config <path>/-c <path>/GATHER_CONFIG=<path>指定;缺省探测工作目录下的gather-server-1.toml(存在才读取)。 - 相对路径(
data_dir、TLS 证书)按启动时的工作目录解析。
server 配置
Section titled “server 配置”| TOML 字段 | 环境变量 | 作用 | 默认 |
|---|---|---|---|
owner_public_key_hex |
GATHER_OWNER_PUBLIC_KEY |
持有者 ed25519 公钥 hex(必填) | — |
server_id |
GATHER_SERVER_ID |
实例 / 服务器 id(全局唯一) | gather-server-1 |
name |
GATHER_NAME |
小组显示名(明文) | My Group |
listen |
GATHER_LISTEN |
监听地址 | 0.0.0.0:8443 |
data_dir |
GATHER_DATA_DIR |
数据目录(SQLite + media/) |
./gather-data |
debug_no_auth |
GATHER_DEBUG_NO_AUTH |
免签调试降级(仅回环监听生效) | 关 |
public_endpoint |
GATHER_PUBLIC_ENDPOINT |
对外 RPC 基址(写入服务器信息、用于邀请与解析) | 空 |
register |
GATHER_REGISTER |
是否上报注册处 / 可被解析 | true |
public |
GATHER_PUBLIC |
是否可被公开组目录搜索(隐含 register=true) |
true |
registry_url |
GATHER_REGISTRY_URL |
注册处基址;置空 = 完全不上报 | 官方注册处 |
cors_allowed_origins |
GATHER_CORS_ALLOWED_ORIGINS |
允许直连 Web 端的来源白名单(逗号分隔) | 空 |
media_max_bytes |
GATHER_MEDIA_MAX_BYTES |
单媒体文件上限(字节) | 104857600(100 MiB) |
[tls] cert + [tls] key |
GATHER_TLS_CERT + GATHER_TLS_KEY |
同时设置 = 启用 TLS | 无(http 直连) |
server_id 规则
Section titled “server_id 规则”- 仅允许小写字母、数字与连字符:
[a-z0-9-]{3,32},不能以-开头或结尾。 - 不可使用保留字:
admin、www、api、registry、gather、support、help、root、mail。 server_id在首次启动时写入数据库;改名等于新建实例,请连同数据目录一起更换。
public_endpoint是 server 对外的完整基址(如https://server.example.com)。它决定了邀请链接与解析结果指向哪里;对外服务时必须配置为公网可访问地址。register=true且public_endpoint、registry_url均非空时,server 会(尽力而为地)向注册处登记,支持:- 按
server_id解析地址(邀请链接可用简短形式); - 被公开组目录按名称搜索(
public=true)。
- 按
- 想彻底退出目录:设
register=false;或设registry_url=""完全不上报。此时邀请需使用带endpoint的直连链接。
浏览器直连(CORS)
Section titled “浏览器直连(CORS)”当 Web 端按 public_endpoint 直接访问 server(与页面不同源)时,需要把该页面的来源加入白名单,例如:
cors_allowed_origins = ["https://app.example.com"]来源须与浏览器地址完全一致(含协议、主机与端口)。原生 App 不受此限制。
owner_public_key_hex = "8a88e3dd7409f195fd52db2d3cba5d72ca6709bf1d94121bf3748801b40f6f5c"server_id = "my-group"name = "我的小组"listen = "0.0.0.0:8443"data_dir = "/srv/gather/data"
public_endpoint = "https://server.example.com"register = truepublic = trueregistry_url = "https://registry.example.com" # 留空则完全不上报
cors_allowed_origins = ["https://app.example.com"]media_max_bytes = 104857600
# 对外 HTTPS(也可交给反向代理,见 TLS 与域名)# [tls]# cert = "/etc/gather/tls/cert.pem"# key = "/etc/gather/tls/key.pem"注册处(身份 / 找回 / 目录服务)默认不发送真实邮件:验证码只写入日志,并直接回显给客户端,便于本地调试。
生产环境需要真实发信时:
- 使用启用 SMTP 的构建 / 镜像;
- 在注册处配置中填写
[smtp]:
[smtp]host = "smtp.example.com"port = 587user = "noreply@example.com"password = "your-app-password"from = "noreply@example.com"- 当前实现使用 587 + STARTTLS;不支持 465 隐式 TLS。
- 建议配置 SPF / DKIM / DMARC,并让
from与发信域一致,否则易被判为垃圾邮件。 - 验证码含限流(同邮箱最小发码间隔、每小时上限、有效期、错误次数上限),可按需调整。