Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Forward HTTPS client ip from Google Container Engine

I'm running an nginx service in a docker container with Google Container Engine which forwards specific domain names to other services, like API, Frontend, etc. I have simple cluster for that with configured services. Nginx Service is Load Balance.

The REMOTE_ADDR environmental variable always contains an internal address in the Kubernetes cluster. I looked for is HTTP_X_FORWARDED_FOR but it's missing from the request headers. Is it possible to configure the service to save the external client ip in the requests?

like image 940
sigrlami Avatar asked Oct 28 '16 18:10

sigrlami


1 Answers

With the current implementation of L3 balancing (as of Kubernetes 1.4) it isn't possible to get the source IP address for a connection to your service.

It sounds like your use case might be well served by using an Ingress object (or by manually creating an HTTP/S load balancer), which will put the source IP address into a the X-Forwarded-For HTTP header for easy retrieval by your backends.

like image 200
Robert Bailey Avatar answered Sep 22 '22 15:09

Robert Bailey