Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/235.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php TrustedProxy未检测到用户IP_Php_Laravel 5_Proxy - Fatal编程技术网

Php TrustedProxy未检测到用户IP

Php TrustedProxy未检测到用户IP,php,laravel-5,proxy,Php,Laravel 5,Proxy,我在ELB和Cloudflare后面的EC2上使用带有PHP7的Laravel 5.3,我对TrustedProxy包()有点问题 软件包没有给我用户Ip 在可信配置文件中,我有如下内容 return [ 'proxies' => '*', 'headers' => [ \Illuminate\Http\Request::HEADER_CLIENT_IP => 'X_FORWARDED_FOR', \Illuminate\H

我在ELB和Cloudflare后面的EC2上使用带有PHP7的Laravel 5.3,我对TrustedProxy包()有点问题

软件包没有给我用户Ip

在可信配置文件中,我有如下内容

return [
    'proxies' => '*',
    'headers' => [
        \Illuminate\Http\Request::HEADER_CLIENT_IP    => 'X_FORWARDED_FOR',
        \Illuminate\Http\Request::HEADER_CLIENT_HOST  => 'X_FORWARDED_HOST',
        \Illuminate\Http\Request::HEADER_CLIENT_PROTO => 'X_FORWARDED_PROTO',
        \Illuminate\Http\Request::HEADER_CLIENT_PORT  => 'X_FORWARDED_PORT',
    ],
];
(我也试过**)

但是,当我执行类似于$request->ip(),$request->getClientIp o getClientIps(最后所有这些方法都使用getClientIps())的操作时,出现的ip就是代理ip

如果我打印$request,我可以看到:

服务器包:

...
"HTTP_X_FORWARDED_PROTO" => "https"
"HTTP_X_FORWARDED_PORT" => "443"
"HTTP_X_FORWARDED_FOR" => "XX.XX.XX.XX" (I removed the real IP)
...
"REMOTE_ADDR" => "10.0.0.53"
头袋:

"x-forwarded-proto" => array:1 [
    0 => "https"
  ]
  "x-forwarded-port" => array:1 [
    0 => "443"
  ]
  "x-forwarded-for" => array:1 [
    0 => "XX.XX.XX.XX" (I removed the real IP)
  ]
但是$request->ip(),$request->getClientIp和getClientIp返回了错误的ip(10.0.0.53)

有人有想法或线索吗

谢谢

已解决。 主要问题(有点愚蠢)是中餐的顺序。我在trustproxy之前执行的中间件中使用了这些信息