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:

$ SERVER [‘HTTPCLIENT_IP’]

$ SERVER ['HTTPXFORWARDEDFOR’]

$ SERVER ['HTTPXFORWARDEDFOR’]

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

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

Hey there,

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

https://blog.digitalocean.com/load-balancers-now-support-proxy-protocol/
https://www.digitalocean.com/docs/networking/load-balancers/how-to/create/#creating-the-load-balancer

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.

Regards,
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?

Submit an Answer