<p>My goal is to make my web application (deployed on Kubernetes 1.4 cluster) see the IP of the client that originally made the HTTP request. As I'm planning to run the application on a bare-metal cluster, GCE and the <code>service.alpha.kubernetes.io/external-traffic: OnlyLocal</code> service annotation introduced in 1.4 is not applicable for me.</p>

<p>Looking for alternatives, I've found <a href="https://stackoverflow.com/questions/32112922/how-to-read-client-ip-addresses-from-http-requests-behind-kubernetes-services">this question</a> which is proposing to set up an Ingress to achieve my goal. So, I've set up the Ingress and <a href="https://github.com/kubernetes/contrib/tree/master/ingress/controllers/nginx" rel="noreferrer">the NginX Ingress Controller</a>. The deployment went smoothly and I was able to connect to my web app via the Ingress Address and port 80. However in the logs I still see cluster-internal IP (from 172.16.0.0/16) range - and that means that the external client IPs are not being properly passed via the Ingress. Could you please tell me what do I need to configure in addition to the above to make it work?</p>

<p>My Ingress' config:</p>

<pre><code>apiVersion: extensions/v1beta1   
kind: Ingress
metadata:
  name: myWebApp
spec:
  backend:
    serviceName: myWebApp
    servicePort: 8080
</code></pre>

<p>As a layer 4 proxy, Nginx cannot retain the original source IP address in the actual IP packets. You can work around this using the <a href="http://www.haproxy.org/download/1.5/doc/proxy-protocol.txt" rel="noreferrer">Proxy protocol</a> (the link points to the HAProxy documentation, but Nginx also supports it).</p>

<p>For this to work however, the upstream server (meaning the <code>myWebApp</code> service in your case) also needs to support this protocol. In case your upstream application also uses Nginx, you can enable proxy protocol support in your server configuration as documented <a href="https://www.nginx.com/resources/admin-guide/proxy-protocol/" rel="noreferrer">in the official documentation</a>.</p>

<p>According to the <a href="https://github.com/kubernetes/contrib/tree/master/ingress/controllers/nginx#proxy-protocol" rel="noreferrer">Nginx Ingress Controller's documentation</a>, this feature can be enabled in the Ingress Controller using a Kubernetes ConfigMap:</p>

<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: nginx-ingress-controller
data:
  use-proxy-protocol: "true"
</code></pre>

<p>Specify the name of the ConfigMap in your Ingress controller manifest, by adding the <code>--nginx-configmap=&lt;insert-configmap-name&gt;</code> flag to the command-line arguments.</p>
