class ReverseProxyMiddleware in Drupal 9
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php \Drupal\Core\StackMiddleware\ReverseProxyMiddleware
Provides support for reverse proxies.
Hierarchy
- class \Drupal\Core\StackMiddleware\ReverseProxyMiddleware implements \Symfony\Component\HttpKernel\HttpKernelInterface
Expanded class hierarchy of ReverseProxyMiddleware
3 files declare their use of ReverseProxyMiddleware
- install.core.inc in core/
includes/ install.core.inc - API functions for installing Drupal.
- ReverseProxyMiddlewareTest.php in core/
tests/ Drupal/ Tests/ Core/ StackMiddleware/ ReverseProxyMiddlewareTest.php - UpdateKernel.php in core/
lib/ Drupal/ Core/ Update/ UpdateKernel.php
1 string reference to 'ReverseProxyMiddleware'
- core.services.yml in core/
core.services.yml - core/core.services.yml
1 service uses ReverseProxyMiddleware
File
- core/
lib/ Drupal/ Core/ StackMiddleware/ ReverseProxyMiddleware.php, line 12
Namespace
Drupal\Core\StackMiddlewareView source
class ReverseProxyMiddleware implements HttpKernelInterface {
/**
* The decorated kernel.
*
* @var \Symfony\Component\HttpKernel\HttpKernelInterface
*/
protected $httpKernel;
/**
* The site settings.
*
* @var \Drupal\Core\Site\Settings
*/
protected $settings;
/**
* Constructs a ReverseProxyMiddleware object.
*
* @param \Symfony\Component\HttpKernel\HttpKernelInterface $http_kernel
* The decorated kernel.
* @param \Drupal\Core\Site\Settings $settings
* The site settings.
*/
public function __construct(HttpKernelInterface $http_kernel, Settings $settings) {
$this->httpKernel = $http_kernel;
$this->settings = $settings;
}
/**
* {@inheritdoc}
*/
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE) {
// Initialize proxy settings.
static::setSettingsOnRequest($request, $this->settings);
return $this->httpKernel
->handle($request, $type, $catch);
}
/**
* Sets reverse proxy settings on Request object.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* A Request instance.
* @param \Drupal\Core\Site\Settings $settings
* The site settings.
*/
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));
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ReverseProxyMiddleware:: |
protected | property | The decorated kernel. | |
ReverseProxyMiddleware:: |
protected | property | The site settings. | |
ReverseProxyMiddleware:: |
public | function | ||
ReverseProxyMiddleware:: |
public static | function | Sets reverse proxy settings on Request object. | |
ReverseProxyMiddleware:: |
public | function | Constructs a ReverseProxyMiddleware object. |