Access external client IP from behind Google Compute Engine network load balancer

Viewed 2630

I am running a Ruby on Rails app (using Passenger in Nginx mode) on Google Container Engine. These pods are sitting behind a GCE network load balancer. My question is how to access the external Client IP from inside the Rails app.

The Github issue here seems to present a solution, but I ran the suggested:

for node in $(kubectl get nodes -o name | cut -f2 -d/); do
  kubectl annotate node $node \
    net.beta.kubernetes.io/proxy-mode=iptables;
  gcloud compute ssh --zone=us-central1-b $node \
    --command="sudo /etc/init.d/kube-proxy restart";
done

but I am still getting a REMOTE_ADDR header of 10.140.0.1.

On ideas on how I could get access to the real Client IP (for geolocation purposes)?

Edit: To be more clear, I am aware of the ways of accessing the client IP from inside Rails, however all of these solutions are getting me the internal Kubernetes IP, I believe the GCE network load balancer is not configured (or perhaps unable) to send the real client IP.

2 Answers
Related