public static function ReverseProxyMiddleware::setSettingsOnRequest in Zircon Profile 8
Same name and namespace in other branches
- 8.0 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.
- ReverseProxyMiddleware::handle in core/
lib/ Drupal/ Core/ StackMiddleware/ ReverseProxyMiddleware.php - Handles a Request to convert it to a Response.
File
- core/
lib/ Drupal/ Core/ StackMiddleware/ ReverseProxyMiddleware.php, line 62 - Contains \Drupal\Core\StackMiddleware\ReverseProxyMiddleware.
Class
- ReverseProxyMiddleware
- Provides support for reverse proxies.
Namespace
Drupal\Core\StackMiddlewareCode
public static function setSettingsOnRequest(Request $request, Settings $settings) {
// Initialize proxy settings.
if ($settings
->get('reverse_proxy', FALSE)) {
$ip_header = $settings
->get('reverse_proxy_header', 'X_FORWARDED_FOR');
$request::setTrustedHeaderName($request::HEADER_CLIENT_IP, $ip_header);
$proto_header = $settings
->get('reverse_proxy_proto_header', 'X_FORWARDED_PROTO');
$request::setTrustedHeaderName($request::HEADER_CLIENT_PROTO, $proto_header);
$host_header = $settings
->get('reverse_proxy_host_header', 'X_FORWARDED_HOST');
$request::setTrustedHeaderName($request::HEADER_CLIENT_HOST, $host_header);
$port_header = $settings
->get('reverse_proxy_port_header', 'X_FORWARDED_PORT');
$request::setTrustedHeaderName($request::HEADER_CLIENT_PORT, $port_header);
$forwarded_header = $settings
->get('reverse_proxy_forwarded_header', 'FORWARDED');
$request::setTrustedHeaderName($request::HEADER_FORWARDED, $forwarded_header);
$proxies = $settings
->get('reverse_proxy_addresses', array());
if (count($proxies) > 0) {
$request::setTrustedProxies($proxies);
}
}
}