feat: add trustedProxies support for Caddy reverse proxy#212
Merged
Conversation
Adds `trustedProxies` field to CaddyConfig. When set, injects Caddy
`servers { trusted_proxies static <CIDRs> }` into the global options
block alongside GCS storage config.
This preserves X-Forwarded-For headers from trusted upstream proxies
(e.g., Cloudflare, GKE LB) instead of overwriting them with the
immediate client IP.
Usage in server.yaml:
```yaml
caddy:
enable: true
trustedProxies:
- "10.0.0.0/8" # GKE internal
- "172.16.0.0/12" # GKE internal
- "173.245.48.0/20" # Cloudflare
- "103.21.244.0/22" # Cloudflare
```
This comment has been minimized.
This comment has been minimized.
Adds `trustedProxies` field to CaddyConfig. When set, injects Caddy
`servers { trusted_proxies static <CIDRs> }` into the global options
block alongside storage config.
This preserves X-Forwarded-For headers from trusted upstream proxies
(e.g., Cloudflare, GKE LB) instead of overwriting them with the
immediate connecting IP.
Changes:
- pkg/clouds/k8s/types.go: add TrustedProxies []string to CaddyConfig
- pkg/clouds/pulumi/kubernetes/caddy_global_opts.go: extracted testable
BuildTrustedProxiesBlock (with CIDR validation) and
BuildCaddyfileGlobalOptions helpers
- pkg/clouds/pulumi/kubernetes/caddy.go: support trustedProxies in
non-GKE (standalone K8s) code path
- pkg/clouds/pulumi/gcp/gke_autopilot.go: use extracted helpers,
validate CIDRs before Pulumi apply
- pkg/clouds/pulumi/kubernetes/caddy_global_opts_test.go: 9 test cases
covering empty, valid, invalid, and combination scenarios
smecsia
previously approved these changes
Apr 1, 2026
… fixtures
ConvertDescriptor (yaml round-trip) produces []string{} instead of nil
for unset slice fields. Normalize in CaddyReadConfig and update test
expected values to match deserialization behavior.
- Unresolved fixture (RefappKubernetesServerResources): nil — matches
CaddyReadConfig normalization after ReadServerDescriptor
- Resolved fixture (ResolvedRefappKubernetesServerResources): []string{}
— matches placeholder resolution which converts nil slices to empty
via reflect deep-copy
- CaddyReadConfig normalizes []string{} → nil after ConvertConfig
smecsia
approved these changes
Apr 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
trustedProxiesfield to CaddyConfig. When set, injects Caddyservers { trusted_proxies static <CIDRs> }into the global options block alongside GCS storage config.This preserves X-Forwarded-For headers from trusted upstream proxies (e.g., Cloudflare, GKE LB) instead of overwriting them with the immediate client IP.
Usage in server.yaml: