-
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
Forward Source IP to Pods behind ingress-nginx #1898
Comments
@Ascendance to preserve the source IP address in that environment you need to enable proxy protocol ( Just in case |
My HAProxy is already configured for
NGINX can see the real external IP of proxied request as per the logs:
My ingress configmap is set as follows:
And my custom header is set as follows:
I have tried a combination of IP's for For all cases curling the HAProxy vm still returns internal IP of 10.244.2.6 @aledbf What should I put for |
I fixed it! The problem was was within the iris web framework. |
@Ascendance how did you fix it? |
I am having the same issue. Default install on a cluster running Kubernetes 1.10 and the source IP is not being passed through. Here's what I get when I run a simple
As you can see there's no "source" IP being passed in any way. Anything else I cloud try? Is there some more info I can provide? |
Not sure in PHP but in go and iris the framework decided to use fast source IP lookup(TL;DR whoever is in front of it) instead of actually inspecting the real IP attached to class ctx headers. You might want to look at how PHP handles REMOTE_ADDR. With go and Iris I was able to get the real IP. So I’m sure it’s somewhere with PHP. |
Is this a BUG REPORT or FEATURE REQUEST? (choose one): Neither. Bug Perhaps?
NGINX Ingress controller version:
quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.9.0
Found here as per the installation guide at time of writing.
Kubernetes version (use
kubectl version
):Environment:
This is currently how my environment is set up:
Internet -> HAProxy vm -> K8S cluster (1 master, 2 worker)
Ingress-nginx is setup according to the bare metal guide. The cluster uses flannel for networking. There is nothing else on it besides a go image that reads client source ip. This image replaces default-backend.
uname -a
):What happened:
I have a vm that sits in front of the cluster. Currently it is running HAProxy but NGINX produces the same results (nginx with
use-proxy-protocol: "true"
). My end goal is to allow the pods associated with the default backend to be able to read the actual source client source IP.Here's a sample log of what happens when
use-proxy-protocol
is turned on or off:142.xx.xxx.xx is the IP of the HAProxy vm
216.249.49.20 is an external IP coming from the university. As you can see, the ingress pod can read external IP's passed from HAProxy with
use-proxy-protocol: "true"
Just fine. This also works with NGINX (on vm outside cluster) withuse-proxy-protocol: "false"
.But when I curl the address of HAProxy vm, I get:
10.244.2.6 is the IP of the ingress pod. I think if I am correct ingress-nginx at this point has the real source IP.
Is there a way to add forward real IP and forward headers to pods behind ingress-nginx via configmaps? From what I can tell here it much of it should be set by default. If not what should I do?
What you expected to happen:
Pods in default backend should read real client source IP. Not the internal IP of the node that the ingress pod sits on.
How to reproduce it (as minimally and precisely as possible):
The text was updated successfully, but these errors were encountered: