public function ReverseProxySubscriber::onKernelRequestReverseProxyCheck

Passes reverse proxy settings to current request.

Parameters

\Symfony\Component\HttpKernel\Event\GetResponseEvent $event: The Event to process.

File

drupal/core/lib/Drupal/Core/EventSubscriber/ReverseProxySubscriber.php, line 43
Contains \Drupal\Core\EventSubscriber\ReverseProxySubscriber.

Class

ReverseProxySubscriber
Reverse proxy subscriber for controller requests.

Namespace

Drupal\Core\EventSubscriber

Code

public function onKernelRequestReverseProxyCheck(GetResponseEvent $event) {
  $request = $event
    ->getRequest();
  if ($this->settings
    ->get('reverse_proxy', 0)) {
    $reverse_proxy_header = $this->settings
      ->get('reverse_proxy_header', 'HTTP_X_FORWARDED_FOR');
    $request::setTrustedHeaderName($request::HEADER_CLIENT_IP, $reverse_proxy_header);
    $reverse_proxy_addresses = $this->settings
      ->get('reverse_proxy_addresses', array());
    $request::setTrustedProxies($reverse_proxy_addresses);
  }
}