By ufirst
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 [‘HTTP_CLIENT_IP’]
$ _SERVER [‘HTTP_X_FORWARDED_FOR’]
$ _SERVER [‘HTTP_X_FORWARDED_FOR’]
But none of these worked, I always get the Load Balancer IP. Can anybody help me?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.