Report this

What is the reason for this report?

Como pegar o IP verdadeiro do usuário, com Load Balancer e LAMP?

Posted on June 11, 2019

Estou usando o Load Balancer e LAMP, na minha aplicação. Porém em uma funcionalidade da minha aplicação é necessário pegar o IP verdadeiro de quem está acessando. Eu tentei com PHP de várias formas como: $_SERVER[‘HTTP_CLIENT_IP’] $_SERVER[‘HTTP_X_FORWARDED_FOR’] $_SERVER[‘HTTP_X_FORWARDED_FOR’] , mas nenhuma dessas funcionou, sempre me retorna o IP do Load Balancer. Alguem poderia me ajudar?



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!

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.

Hello,

To fix the problem you need to make sure that the remoteip_module Apache module is loaded.

You can follow the steps listed in the answer here on how to setup and configure that:

https://www.digitalocean.com/community/questions/get-client-public-ip-on-apache-server-used-behind-load-balancer

Hope that this helps! Regards, Bobby

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.