Get User IP Address From Google Cloud Load Balancer

Posted on January 23, 2019 at 1:48 pm

Google Cloud Load Balancer saves the user’s IP in the X-Forwarded-For field:

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

More information can be found here:

Here is a sample PHP snippet to get the user’s IP address:

$user_ip = explode(",", $_SERVER['HTTP_X_FORWARDED_FOR'])[0];

Receive updates via email

Other Posts

Updated Posts