<p>We run a Kubernetes cluster hosting a database, various microservices and an <code>nginx</code> reverse proxy, all in containers. We have a Google <a href="https://kubernetes.io/docs/concepts/services-networking/service/#type-loadbalancer" rel="nofollow noreferrer">load balancer</a> and a forwarding rule that forwards to the reverse proxy, and from there requests are proxied to the appropriate microservice.</p>

<p>This works well, however the reverse proxy is never shown the IP address of clients connecting to it. (Despite <a href="https://cloud.google.com/compute/docs/load-balancing/http/" rel="nofollow noreferrer">this documentation</a> indicating that it is possible to obtain this information via HTTP headers, we've had no luck and only ever see IPs on our GCP <code>default</code> network.)</p>

<p>Following a suggestion in another SO question - whose link I've temporarily mislaid - I want to deploy <code>nginx</code> on a VM instance instead, where it <em>does</em> have access to a connecting client's IP, and then forward requests from that instance into the cluster.</p>

<p>My question then is this: Each microservice listens on a TCP port and has a k8s <code>Service</code> configured. How can I refer to these k8s <code>Service</code>s from within my <code>nginx</code> VM? Can I do it via DNS or via ingress controllers?</p>

<p>Alternatively if you <em>can</em> in fact determine external IP addresses behind a Google Load balancer I'd much rather do that. I remember reading a very long k8s GitHub issue about it showing that that was some way off yet.</p>

<p>What you are looking for is called <code>http proxy protocol</code></p>

<p><a href="https://www.nginx.com/resources/admin-guide/proxy-protocol/" rel="nofollow noreferrer">https://www.nginx.com/resources/admin-guide/proxy-protocol/</a></p>

<p>Note that both google load balancer and your nginx must be configured to use the proxy protocol at the same time.
If one of them is using proxy protocol, and the other not using, nothing will work.</p>
