feat: add configurable real_ip_header option for nginx #904
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.
Add configurable
real_ip_headeroption for nginx configurationSummary
This PR makes the nginx
real_ip_headerdirective configurable viavalues.yaml, allowing users to customize which header is used to extract the real client IP address.Changes
apisix.nginx.realIpHeaderconfiguration option invalues.yamlwith a default value of"X-Real-IP"configmap.yamltemplate to use the configurable value instead of hardcoded"X-Real-IP""X-Real-IP")Why This Change is Necessary
Different deployment environments and proxy setups use different headers to pass the original client IP address:
Load Balancer Variations: Different cloud providers and load balancers use different headers:
X-Forwarded-ForCF-Connecting-IPX-Forwarded-ForX-Real-IP(current default)Multi-Layer Proxy Environments: In complex deployments with multiple proxy layers (e.g., CDN → Load Balancer → Ingress → APISIX), the appropriate header may differ based on architecture.
Security and Rate Limiting: Correctly identifying client IPs is crucial for:
Flexibility: Without this configuration option, users would need to either:
This change provides the flexibility needed for various deployment scenarios while maintaining sensible defaults.
Usage Example
Or via Helm CLI: