<p>How can I preserve origin client IP when using ingress-controller on Kubernetes?</p>

<p>I didn't see any solution in the documentation.</p>

<p>This link is broken: <a href="http://ingress.kubernetes.io/preserve-host" rel="nofollow noreferrer">http://ingress.kubernetes.io/preserve-host</a></p>

0x77dev
<p>From the <a href="https://kubernetes.github.io/ingress-nginx/user-guide/miscellaneous/#source-ip-address" rel="nofollow noreferrer">doc</a></p>

<p>By default NGINX uses the content of the header <code>X-Forwarded-For</code> as the source of truth to get information about the client IP address. This works without issues in L7 if we configure the setting proxy-real-ip-cidr with the correct information of the IP/network address of trusted external load balancer.</p>

<p>If the ingress controller is running in AWS we need to use the VPC IPv4 CIDR.</p>

<p>Another option is to enable proxy protocol using <code>use-proxy-protocol: "true"</code>.</p>

<p>In this mode NGINX does not use the content of the header to get the source IP address of the connection.</p>

<p>If you are using a L4 proxy to forward the traffic to the NGINX pods and terminate HTTP/HTTPS there, you will lose the remote endpoint's IP address. To prevent this you could use the Proxy Protocol for forwarding traffic, this will send the connection details before forwarding the actual TCP connection itself.</p>

<p>Amongst others ELBs in AWS and HAProxy support Proxy Protocol.</p>
