-
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
Add a way to customize X-Forwarded-For #10749
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/test-infra repository. |
@stac47 There is another load balancer when you deploy it into AWS that would need the settings in the ELB like the other one. Ingress deploys a service type of LoadBalancer and the cloud controller deploys one for Ingress to use. |
@strongjz I have a very similar case. I want to support both NLB using (proxy protocol) and ALB using client port preservation, but use-forwarded-headers behavior is odd ie. it removes the client port. We often need this for government/police requests. Potentially in the future I will also need to support CloudFront 😅 So far, I have had to use two separate nginx ingress for ALB and NLB (it depends on use case) For ALB
For NLB
For .NET we need the addr:port because how .NET parses forwarded for header. With proxy protocol the x-forwarded-for gets an ip at least without the with ALB and client port preservation the So yes it seems very much like I want some sort of customization that allows me for one to have conditional so I could use the same load balancer with minimal configuration change. Example of the headers:
|
@strongjz Hello, I updated the schema to be closer to my infrastructure.
Not sure to understand. Do you mean my proposal would not work? |
We have slightly the same issue, but with CloudFlare, not CloudFront. Temporary solution is splitting Ingresses and add annotation to the second one (for clients with CF): nginx.ingress.kubernetes.io/configuration-snippet: |
proxy_set_header X-Forwarded-For $http_cf_connecting_ip; Similar issues: |
Hello everyone,
I am trying to configure my ingress-nginx controller so that the applications
hosted in a Kubernetes cluster can see the real remote IP of the client.
My case is only based on
X-Forwarded-For
header and I cannot move the PROXYprotocol immediately.
Let's image the situation of application hosted in AWS that can be accessed in
different ways:
Balancer
This means the traversed trusted (inside AWS) proxies are either in the VPC
(second case) our outside of the VPC (first case).
More visually, let's take two clients:
With the following configuration, as described in the documentation
(https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/#proxy-real-ip-cidr):
The applications will receive the correct Client 2 IP address (because the
client is right at the boundary of the VPC). But the application will only see
the CloudFront machine IP when the requests are sent by Client 1.
One solution to cope with this issue could be to add the public IPs of
CloudFront that are published by AWS at
https://ip-ranges.amazonaws.com/ip-ranges.json. But that introduce some static
configuration and regular updates of the AWS IPs.
But a more dynamic solution could be to rely upon the CloudFront headers. For
Client 1, I think the best source of true should be in the added header
CloudFront-Viewer-Address
.So I was thinking to a solution in which I could create a
$custom_forwarded_for
variable which would be used to set the correct valueto the
X-Forwarded-For
header to send to the application.Something like this could do the trick:
The problem is that it cannot be used easily. The default template force this
line:
This line is as far as I know impossible to override. Using
more_set_input_headers
will not help and reusingproxy_set_header
wouldonly append the list.
So at that point I can see only solution:
I was wondering whether there was a more straightforward way to send the custom
X-Forwarded-For
header.I was thinking of an new configuration like
custom-forwarded-for-variable
. Forinstance, we could have the following configuration in the ConfigMap:
The official template could then be modified that way:
There are probably better solution that I would be happy to read.
I can see there are several issues related to mine (for instance), and think with this change, it would simply the management of other connectivities (like taking the CloudFlare's
CF-Remote-IP
header when needed).Thanks in advance for your feedbacks or better solution to solve this usecase.
The text was updated successfully, but these errors were encountered: