-
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
X-Forwarded-For is not updated from proxy_protocol when terminating TLS #1443
Comments
FWIW after reading #1381 I tried test image 0.240, but that seems even worse in that for both TLS and non-TLS it just passes on the left-most IP address in the X-Forwarded-For list (no matter with the other entries are). |
@abh when you use proxy_protocol X-Forwarded-For is omitted. |
@abh please use quay.io/aledbf/nginx-ingress-controller:0.243 |
Yup, 0.243 fixes the security issue of trusting the X-Forwarded-For and the feature of getting the actual client IP there. It'd be nice if it could still be properly conforming to how the header should work (adding the IP) so chains of proxies can work. (For example the real IP might be a CDN server; if the application knows or can lookup the IPs of the CDN servers it can choose to trust the next IP in the X-Forwarded-For chain). |
@abh can you test the image with real traffic behind a proxy? This should work (set proxy-real-ip-cidr). There is no code for this. This is just nginx with the real_ip module |
We can choose between the correct IP address or let the app handle this. Why? If nginx c |
Your sentence got cut off ... The proper way is to add the correct IP at the end of the list. Then the application can choose which if any of the "upstream" proxies it will trust; or it can just trust the last one (the ingress). |
@abh sorry :) |
Not if you add the correct IP address at the end. That's how the header works. |
@abh sure, but that can be a fake IP address. Edit: please try to see this from my point of view. I cannot fulfill all the uses cases. In this case I prefer to use the have the real IP address |
@abh can you provide a full working example of what you expect? (just to be able to reproduce what you see) |
Sorry, I use this for a hobby project and sometimes I don't have time on continuous days to fuss with it. The user will get the real IP address, or rather all the real IP addresses if the header is implemented correctly. One use case, for example, is getting the end-user IP when the site is behind a CDN. Cloudflare for example publish a list of their IPs. Processing the X-Forwarded-For header the application can say "yes, the next IP was from my CDN so we'll also look at the next IP after that". (Also continued in #1489) |
Using nginx ingress controller .13 it appears the X-Forwarded-For header isn't updated on TLS connections when proxy_protocol is enabled.
I setup an httpbin that shows this, I hope:
No TLS, my IP is added to X-Forwarded-For:
With TLS, it's not:
Note that if the client doesn't set an X-Forwarded-For header the right IP address is added to the header, but if the header already exists it's passed straight through without the "real IP" being added (oops!).
I have "proxy-real-ip-cidr" set to "10.0.100.0/24" (which is where our load balancers are). See also #1000.
The text was updated successfully, but these errors were encountered: