You are here

public static function ReverseProxyMiddleware::setSettingsOnRequest in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php \Drupal\Core\StackMiddleware\ReverseProxyMiddleware::setSettingsOnRequest()
  2. 9 core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php \Drupal\Core\StackMiddleware\ReverseProxyMiddleware::setSettingsOnRequest()

Sets reverse proxy settings on Request object.

Parameters

\Symfony\Component\HttpFoundation\Request $request: A Request instance.

\Drupal\Core\Site\Settings $settings: The site settings.

2 calls to ReverseProxyMiddleware::setSettingsOnRequest()
install_begin_request in core/includes/install.core.inc
Begins an installation request, modifying the installation state as needed.
UpdateKernel::handle in core/lib/Drupal/Core/Update/UpdateKernel.php

File

core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php, line 59

Class

ReverseProxyMiddleware
Provides support for reverse proxies.

Namespace

Drupal\Core\StackMiddleware

Code

public static function setSettingsOnRequest(Request $request, Settings $settings) {

  // Initialize proxy settings.
  if ($settings
    ->get('reverse_proxy', FALSE)) {
    $proxies = $settings
      ->get('reverse_proxy_addresses', []);
    if (count($proxies) > 0) {

      // Set the default value. This is the most relaxed setting possible and
      // not recommended for production.
      $trusted_header_set = Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_HOST | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO | Request::HEADER_FORWARDED;
      $request::setTrustedProxies($proxies, $settings
        ->get('reverse_proxy_trusted_headers', $trusted_header_set));
    }
  }
}