You should only list the reverse proxies that you manage directly.
public static setTrustedProxies ( array $proxies ) | ||
$proxies | array | A list of trusted proxies |
use Symfony\Component\HttpFoundation\Request; $request = Request::createFromGlobals(); $request->setTrustedProxies(['192.0.0.1', '10.0.0.0/8']);
use Symfony\Component\HttpFoundation\Request; $request = Request::createFromGlobals(); $request->setTrustedProxies(['192.0.0.1'], Request::HEADER_X_FORWARDED_FOR);
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; $requestStack = new RequestStack(); $request = new Request([], [], [], [], [], [], '{}'); $requestStack->push($request); $request->setTrustedProxies(['192.0.0.1'], Request::HEADER_X_FORWARDED_FOR); $otherRequest = $requestStack->getCurrentRequest();In this example, we are creating a new `RequestStack` object and pushing a new `Request` object onto the stack. We then set the trusted proxies and get the current request from the stack. In conclusion, `setTrustedProxies()` is a method provided by the HttpFoundation component of the Symfony PHP framework that allows developers to specify which proxies should be trusted for determining the client IP address. It helps in cases where applications are deployed behind one or more proxies, and is part of the Symfony HttpFoundation component.
public static setTrustedProxies ( array $proxies ) | ||
$proxies | array | A list of trusted proxies |