-
Notifications
You must be signed in to change notification settings - Fork 8.4k
the_real_ip not capturing correct client ip from cloudfront #3172
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
Comments
something like
(please check the addresses) |
Thanks @aledbf, appreciate your help. We did try that, setting multiple ranges and still resulted in an incorrect IP shown in logs. For the moment, we have decided to switch to using an NLB , and disabling proxy_protocol, which has resulted in the behavior we required for the ingress controller (NLB's are pure TCP, and have no http header concept) |
Unfortunately, NLBs turned out to be too experimental in their implementation. I can definitely confirm @aledbf that no matter what I see to try, proxy-real-ip-cidr configmap does not seem to work as its intended. I can confirm when i alter log message format, x-forwarded-for has the true client (real) ip. |
@timm088 were you able to find a viable solution for the problem? I'm also running into this. |
abandoned from our side for now, returned to ELBs due to some instability in NLBs being 'alpha' supported only. @eseliger |
@timm088 @aledbf We experience the same issue. I believe the main issue is
Cloudfront will transfer the address via |
We have gone with using https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/#compute-full-forwarded-for This will ensure you retain the entire structure of x-forwarded-for when using cloudfront Its not the best (depending on what the downstream service is doing here), but we've found it to be the most reliable. |
@timm088 Yes, that works and will keep the IP in |
I wonder if forcing the use of ingress-nginx/rootfs/etc/nginx/template/nginx.tmpl Lines 127 to 134 in 8cee8d5
|
Here is a possible solution to the issue: https://www.getpagespeed.com/server-setup/nginx/how-to-use-multiple-real-ip-headers-with-nginx |
Uh oh!
There was an error while loading. Please reload this page.
Is this a BUG REPORT or FEATURE REQUEST? (choose one): Possible bug?
NGINX Ingress controller version: 0.17.1
Kubernetes version (use
kubectl version
): 1.10.3What happened:
When using use-proxy-protocol: "true", config within nginx.conf is created with
real_ip_header proxy_protocol;
If i add an additional message to the logs to print $http_x_forwarded_for, we see the 'real' client ip.
However, $the_real_ip contains what we assume is the last IP of the x-forwarded-for, not the first (which is the real client ip).
What you expected to happen:
Client ip would be stored in $the_real_ip
Anything else we need to know:
Only appears to happen with cloudfront > elb > ingress
When we bypass cloudfront, the ELB only has a single entry in x-forwarded-for. Looks to be related to multi entry x-forwarded-for
The text was updated successfully, but these errors were encountered: