mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: implement selective MITM with configurable domain allowlist in aibridgeproxyd (#21473)
## Description Implements selective MITM (Man-in-the-Middle) in `aibridgeproxyd` so that only requests to allowlisted domains are intercepted and decrypted. Requests to all other domains are tunneled directly without decryption. ## Changes * New config option: `CODER_AIBRIDGE_PROXY_DOMAIN_ALLOWLIST` (default: `api.anthropic.com`,`api.openai.com`) * Selective MITM: Uses `goproxy.ReqHostIs()` to only intercept `CONNECT` requests to allowlisted hosts * Certificate caching: Now only generates/caches certificates for allowlisted domains * Validation: Startup fails if domain allowlist is empty or contains invalid entries Closes: https://github.com/coder/internal/issues/1182
This commit is contained in:
+16
-4
@@ -3526,6 +3526,17 @@ Write out the current server config as YAML to stdout.`,
|
||||
Group: &deploymentGroupAIBridgeProxy,
|
||||
YAML: "key_file",
|
||||
},
|
||||
{
|
||||
Name: "AI Bridge Proxy Domain Allowlist",
|
||||
Description: "Comma-separated list of domains for which HTTPS traffic will be decrypted and routed through AI Bridge. Requests to other domains will be tunneled directly without decryption.",
|
||||
Flag: "aibridge-proxy-domain-allowlist",
|
||||
Env: "CODER_AIBRIDGE_PROXY_DOMAIN_ALLOWLIST",
|
||||
Value: &c.AI.BridgeProxyConfig.DomainAllowlist,
|
||||
Default: "api.anthropic.com,api.openai.com",
|
||||
Hidden: true,
|
||||
Group: &deploymentGroupAIBridgeProxy,
|
||||
YAML: "domain_allowlist",
|
||||
},
|
||||
|
||||
// Retention settings
|
||||
{
|
||||
@@ -3620,10 +3631,11 @@ type AIBridgeBedrockConfig struct {
|
||||
}
|
||||
|
||||
type AIBridgeProxyConfig struct {
|
||||
Enabled serpent.Bool `json:"enabled" typescript:",notnull"`
|
||||
ListenAddr serpent.String `json:"listen_addr" typescript:",notnull"`
|
||||
CertFile serpent.String `json:"cert_file" typescript:",notnull"`
|
||||
KeyFile serpent.String `json:"key_file" typescript:",notnull"`
|
||||
Enabled serpent.Bool `json:"enabled" typescript:",notnull"`
|
||||
ListenAddr serpent.String `json:"listen_addr" typescript:",notnull"`
|
||||
CertFile serpent.String `json:"cert_file" typescript:",notnull"`
|
||||
KeyFile serpent.String `json:"key_file" typescript:",notnull"`
|
||||
DomainAllowlist serpent.StringArray `json:"domain_allowlist" typescript:",notnull"`
|
||||
}
|
||||
|
||||
type AIConfig struct {
|
||||
|
||||
Reference in New Issue
Block a user