diff --git a/src/gateway/server-runtime-config.ts b/src/gateway/server-runtime-config.ts index a155c5d0a..87f8dbdd7 100644 --- a/src/gateway/server-runtime-config.ts +++ b/src/gateway/server-runtime-config.ts @@ -74,6 +74,8 @@ export async function resolveGatewayRuntimeConfig(params: { const canvasHostEnabled = process.env.CLAWDBOT_SKIP_CANVAS_HOST !== "1" && params.cfg.canvasHost?.enabled !== false; + const trustedProxies = params.cfg.gateway?.trustedProxies ?? []; + assertGatewayAuthConfigured(resolvedAuth); if (tailscaleMode === "funnel" && authMode !== "password") { throw new Error( @@ -89,6 +91,20 @@ export async function resolveGatewayRuntimeConfig(params: { ); } + // Trusted-proxy mode validations + if (authMode === "trusted-proxy") { + if (isLoopbackHost(bindHost)) { + throw new Error( + "gateway auth mode=trusted-proxy makes no sense with bind=loopback; use bind=lan or bind=custom with gateway.trustedProxies configured", + ); + } + if (trustedProxies.length === 0) { + throw new Error( + "gateway auth mode=trusted-proxy requires gateway.trustedProxies to be configured with at least one proxy IP", + ); + } + } + return { bindHost, controlUiEnabled,