We run a Kubernetes cluster hosting a database, various microservices and an nginx
reverse proxy, all in containers. We have a Google load balancer and a forwarding rule that forwards to the reverse proxy, and from there requests are proxied to the appropriate microservice.
This works well, however the reverse proxy is never shown the IP address of clients connecting to it. (Despite this documentation 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 default
network.)
Following a suggestion in another SO question - whose link I've temporarily mislaid - I want to deploy nginx
on a VM instance instead, where it does have access to a connecting client's IP, and then forward requests from that instance into the cluster.
My question then is this: Each microservice listens on a TCP port and has a k8s Service
configured. How can I refer to these k8s Service
s from within my nginx
VM? Can I do it via DNS or via ingress controllers?
Alternatively if you can 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.
What you are looking for is called http proxy protocol
https://www.nginx.com/resources/admin-guide/proxy-protocol/
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.