How to get the true IP of the user with Load Balancer and LAMP?

June 11, 2019 528 views
Ubuntu Apache PHP DigitalOcean Load Balancing

I’m using Load Balancer and LAMP in my application.
But in a feature of my application it is necessary to get the true IP of who is accessing.
I tried with PHP in several ways like:




But none of these worked, I always get the Load Balancer IP. Can anybody help me?

1 Answer

Hey there,

You’ll need to enable proxy protocol for the load balancer to forward the client IP.

If you continue having issues after enabling proxy protocol for your LB just let me know and I can offer additional advice based on the issue you are facing.

Ethan Fox
Developer Support Engineer II - DigitalOcean

  • Thanks for the answer. I use apache in a ubuntu 16.04 droplet. The version of my apache is 2.4.18 and to use the RemoteIPProxyProtocol I need version 2.4.31 or newer. I looked and I did not find how to upgrade, could you help me?

Have another answer? Share your knowledge.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!