Laravel5.5升级到5.6出现的问题setTrustedProxies must be of the type integer, array given, called in - 小众知识

Laravel5.5升级到5.6出现的问题setTrustedProxies must be of the type integer, array given, called in

2018-10-11 03:29:18 苏内容
  标签: Laravel
阅读:7250

 Upgrade problem from 5.5 Argument 2 passed to Symfony\Component\HttpFoundation\Request::setTrustedProxies() must be of the type integer, array given, called in /home/sergi/Code/lanparty/vendor/fideloper/proxy/src/TrustProxies.php on line 54



As stated in the upgrade guide, you need to set the $headers property in App\Http\Middleware\TrustProxies to a bit property.

The constants are defined in Symfony\Component\HttpFoundation\Request.

const HEADER_FORWARDED = 0b00001; // When using RFC 7239
const HEADER_X_FORWARDED_FOR = 0b00010;
const HEADER_X_FORWARDED_HOST = 0b00100;
const HEADER_X_FORWARDED_PROTO = 0b01000;
const HEADER_X_FORWARDED_PORT = 0b10000;
const HEADER_X_FORWARDED_ALL = 0b11110; // All "X-Forwarded-*" headers
const HEADER_X_FORWARDED_AWS_ELB = 0b11010; // AWS ELB doesn't send X-Forwarded-Host

In the upgrade guide, HEADER_X_FORWARDED_ALL is used but you can use a combination of the bit values.

Trusted Proxies

Due to underlying changes in the trusted proxy functionality of Symfony HttpFoundation, slight changes must be made to your application's App\Http\Middleware\TrustProxies middleware.

The $headers property, which was previously an array, is now a bit property that accepts several different values. For example, to trust all forwarded headers, you may update your $headers property to the following value:

use Illuminate\Http\Request;/**
 * The headers that should be used to detect proxies.
 *
 * @var int
 */protected $headers = Request::HEADER_X_FORWARDED_ALL;//需要更改的就是此处

For more information on the available $headers values, check out the full documentation on trusting proxies.


Ok solved reading Upgrade Guide (sorry guys).

Please if you have also this issue see Trusted proxies section at:

https://laravel.com/docs/5.6/upgrade


扩展阅读
相关阅读
© CopyRight 2010-2021, PREDREAM.ORG, Inc.All Rights Reserved. 京ICP备13045924号-1