-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get real ip client with x-forwarded-for header #12702
Comments
This issue is currently awaiting triage. If Ingress contributors determines this is a relevant issue, they will accept it by applying the The Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Helm chart version: |
You can trust proxies using For example, I list rfc1918 space (internal proxies) as well as cloudflare ranges to trust. Instead of X-Forwarded-For I use CF-Connecting-IP, for separate reasons, but here's an example config. spec:
values:
controller:
config:
proxy-real-ip-cidr: "10.0.0.0/8,173.245.48.0/20,..."
use-forwarded-headers: "true"
enable-real-ip: "true"
forwarded-for-header: "CF-Connecting-IP"
... |
I GOT IT!!! Thanks my brother!! @alphabet5 |
Anyway, I needed to set:
with |
This is the nginx.conf in a controller with the above set in the helm chart ^
|
I will test it, thank you very much. |
It worked here. Thank you very much for your help. |
Hello NGINX Ingress Controller Team,
I’m encountering an issue with the $remote_addr variable and would like some guidance on how to solve it.
Here is my current ConfigMap configuration:
My log format is as follows:
However, in my actual logs, I’m seeing these values:
The issue is that $remote_addr is taking the last value from the X-Forwarded-For header, but the real client IP is the first value in that header.
What would be the correct configuration or approach to ensure that $remote_addr captures the first IP in the X-Forwarded-For header instead of the last one?
I would like to use the $remote_addr variable with the annotation nginx.ingress.kubernetes.io/whitelist-source-range and stop using snippets.
Any help or guidance would be greatly appreciated!
Thank you! (edited)
The text was updated successfully, but these errors were encountered: