Home Ask Login Register

Developers Planet

Your answer is one click away!

keoir February 2016

Getting Orgin IP From Load Balancer

Is there a way to get the origin IP of the user from the HTTP load balancing w/ GCloud? We are currently using just Network Load Balancing, and are needing to move to a cross region balancer although we need to user's IP for compliance and logging.

Does it pass in a header or something along those lines?

Thanks ~Z

Answers


keoir February 2016

Ok, so after digging though headers and other things I found the following header that is passing the origin IP and thee IP for the user.

$_SERVER['HTTP_X_FORWARDED_FOR']

You will need to split it by the ',' and take the first part of the string. This is the user IP, that is being pushed by the Google Cloud HTTP Balancer.

~Z


Matt S. February 2016

The documentation (https://cloud.google.com/compute/docs/load-balancing/http/) says it's the first IP address of the X-Forwarded-For header.

  X-Forwarded-For: <client IP(s)>, <global forwarding rule external IP>

Post Status

Asked in February 2016
Viewed 3,422 times
Voted 14
Answered 2 times

Search




Leave an answer


Quote of the day: live life