in laravel когда я хочу получить IP-адрес посетителя от request()->getClientIp()
, он всегда показывает мой IP-адрес сервера и выводит его неверно, я читал об этой проблеме, я думаю, что это связано с cloudflare и laravel TrustProxies, но я не знаете, что мне делать.
как получить реальный IP-адрес посетителя?
вот мой $ _Server dump
array:42 [
"REDIRECT_STATUS" => "200"
"HTTP_X_FORWARDED_HOST" => "dpaper.ir"
"HTTP_X_FORWARDED_PROTO" => "https"
"HTTP_X_FORWARDED_PORT" => "443"
"HTTP_X_FORWARDED_FOR" => "::ffff:46.225.69.114"
"HTTP_COOKIE" => "_ga=GA1.2.199690116.1583749582; _gid=GA1.2.452860032.1584212542; remember_web_59ba36addc2b2f9401580f014c7f58ea4e30989d=eyJpdiI6ImhYWmc5OW4zTktlakRhWDRYTmpGNmc9P"
"HTTP_ACCEPT_LANGUAGE" => "en-US,en;q=0.9,fa;q=0.8,th;q=0.7"
"HTTP_ACCEPT_ENCODING" => "gzip, deflate, br"
"HTTP_SEC_FETCH_USER" => "?1"
"HTTP_SEC_FETCH_MODE" => "navigate"
"HTTP_SEC_FETCH_SITE" => "none"
"HTTP_ACCEPT" => "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"
"HTTP_USER_AGENT" => "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36"
"HTTP_UPGRADE_INSECURE_REQUESTS" => "1"
"HTTP_CONNECTION" => "keep-alive"
"HTTP_HOST" => "dpaper.ir"
"PATH" => "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
"SERVER_SIGNATURE" => "<address>Apache/2.4.25 (Debian) Server at dpaper.ir Port 80</address>"
"SERVER_SOFTWARE" => "Apache/2.4.25 (Debian)"
"SERVER_NAME" => "dpaper.ir"
"SERVER_ADDR" => "10.11.172.198"
"SERVER_PORT" => "80"
"REMOTE_ADDR" => "10.11.81.123"
"DOCUMENT_ROOT" => "/var/www/html/public"
"REQUEST_SCHEME" => "http"
"CONTEXT_PREFIX" => ""
"CONTEXT_DOCUMENT_ROOT" => "/var/www/html/public"
"SERVER_ADMIN" => "webmaster@localhost"
"SCRIPT_FILENAME" => "/var/www/html/public/index.php"
"REMOTE_PORT" => "35058"
"REDIRECT_URL" => "/testi"
"GATEWAY_INTERFACE" => "CGI/1.1"
"SERVER_PROTOCOL" => "HTTP/1.1"
"REQUEST_METHOD" => "GET"
"QUERY_STRING" => ""
"REQUEST_URI" => "/testi"
"SCRIPT_NAME" => "/index.php"
"PHP_SELF" => "/index.php"
"REQUEST_TIME_FLOAT" => 1584720819.106
"REQUEST_TIME" => 1584720819
"argv" => []
"argc" => 0
]