function Request::setTrustedProxies
Sets a list of trusted proxies.
You should only list the reverse proxies that you manage directly.
Parameters
array $proxies A list of trusted proxies, the string 'REMOTE_ADDR' will be replaced with $_SERVER['REMOTE_ADDR'] and 'PRIVATE_SUBNETS' by IpUtils::PRIVATE_SUBNETS:
int-mask-of<Request::HEADER_*> $trustedHeaderSet A bit field to set which headers to trust from your proxies:
2 calls to Request::setTrustedProxies()
- Kernel::preBoot in vendor/
symfony/ http-kernel/ Kernel.php - SubRequestHandler::handle in vendor/
symfony/ http-kernel/ HttpCache/ SubRequestHandler.php
File
-
vendor/
symfony/ http-foundation/ Request.php, line 539
Class
- Request
- Request represents an HTTP request.
Namespace
Symfony\Component\HttpFoundationCode
public static function setTrustedProxies(array $proxies, int $trustedHeaderSet) : void {
if (false !== ($i = array_search('REMOTE_ADDR', $proxies, true))) {
if (isset($_SERVER['REMOTE_ADDR'])) {
$proxies[$i] = $_SERVER['REMOTE_ADDR'];
}
else {
unset($proxies[$i]);
$proxies = array_values($proxies);
}
}
if (false !== ($i = array_search('PRIVATE_SUBNETS', $proxies, true)) || false !== ($i = array_search('private_ranges', $proxies, true))) {
unset($proxies[$i]);
$proxies = array_merge($proxies, IpUtils::PRIVATE_SUBNETS);
}
self::$trustedProxies = $proxies;
self::$trustedHeaderSet = $trustedHeaderSet;
}