<p>I've an gce ingress controller pointing to a service type <code>NodePort</code>.</p>

<p>Is there a way to preserve the client's ip?
I've tried this from <a href="https://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/#preserving-the-client-source-ip" rel="nofollow noreferrer">here</a>, but it didn't work.</p>

<pre><code>service.spec.externalTrafficPolicy = Local
</code></pre>

<p>I found some ways to do for nginx but none for an gce ingress.</p>

<p>The original ip comes in the <code>X-Forwarded-For</code> header. If you're using rails it may come as <code>HTTP_X_FORWARDED_FOR</code></p>

<p><a href="https://cloud.google.com/compute/docs/load-balancing/http/" rel="nofollow noreferrer">https://cloud.google.com/compute/docs/load-balancing/http/</a></p>
