feat(saas): add trusted_proxies config for reverse proxy rate limiting

- Add trusted_proxies field to ServerConfig (Vec<String>, serde default)
- Default value is empty vector (no proxy trust until explicitly configured)
- Development config: trust localhost IPs (127.0.0.1, ::1)
- Production config: placeholder localhost IPs with comment to replace
This commit is contained in:
iven
2026-03-31 16:14:57 +08:00
parent 9905a8d0d5
commit a3bdf11d9a
3 changed files with 7 additions and 0 deletions

View File

@@ -5,6 +5,7 @@
host = "0.0.0.0"
port = 8080
cors_origins = [] # 空 = 开发模式允许所有来源
trusted_proxies = ["127.0.0.1", "::1"]
[database]
url = "postgres://postgres:123123@localhost:5432/zclaw"

View File

@@ -6,6 +6,7 @@ host = "0.0.0.0"
port = 8080
# 生产环境必须配置 CORS 白名单
cors_origins = ["https://admin.zclaw.ai", "https://zclaw.ai"]
trusted_proxies = ["127.0.0.1", "::1"] # 替换为实际代理 IP
[database]
# 生产环境通过 ZCLAW_DATABASE_URL 环境变量覆盖,此处为占位