Answer the question
In order to leave comments, you need to log in
How to pass real IP to Laravel?
There is a project on Laravel, under docker (php-fpm 7.4, nginx stable alpine). I'm trying to get the client's IP in the request, but I end up getting the docker's IP. I just tried everything: nginx'a, docker-compos'a configs - all to no avail. The IP of the company is white, the ports are open.
Answer the question
In order to leave comments, you need to log in
$ipaddress = '';
if (isset($_SERVER['HTTP_CLIENT_IP']))
$ipaddress = $_SERVER['HTTP_CLIENT_IP'];
else if (isset($_SERVER['HTTP_X_FORWARDED_FOR']))
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
else if (isset($_SERVER['HTTP_X_FORWARDED']))
$ipaddress = $_SERVER['HTTP_X_FORWARDED'];
else if (isset($_SERVER['HTTP_FORWARDED_FOR']))
$ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
else if (isset($_SERVER['HTTP_FORWARDED']))
$ipaddress = $_SERVER['HTTP_FORWARDED'];
else if (isset($_SERVER['REMOTE_ADDR']))
$ipaddress = $_SERVER['REMOTE_ADDR'];
else
$ipaddress = 'UNKNOWN';
return $ipaddress;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question