Support for the following settings in deprecated from Drupal 8.7.0:
- reverse_proxy_header
- reverse_proxy_proto_header
- reverse_proxy_host_header
- reverse_proxy_port_header
- reverse_proxy_forwarded_header
In Drupal 8 these could be set to custom header names if used by your reverse proxy. Support for this will be dropped in Drupal 9.
Additionally you could set each value to NULL to indicate that the corresponding header was not to be trusted. In Drupal 8.7.0 a new reverse_proxy_trusted_headers setting has been added to control this.
Before
$settings['reverse_proxy_host_header'] = NULL
$settings['reverse_proxy_forwarded_header'] = NULL;
After
$settings['reverse_proxy_trusted_headers'] = \Symfony\Component\HttpFoundation\Request::HEADER_X_FORWARDED_FOR |
\Symfony\Component\HttpFoundation\Request::HEADER_X_FORWARDED_PROTO | \Symfony\Component\HttpFoundation\Request::HEADER_X_FORWARDED_PORT;
OR
$settings['reverse_proxy_trusted_headers'] = \Symfony\Component\HttpFoundation\Request::HEADER_X_FORWARDED_AWS_ELB
Note the default value for $settings['reverse_proxy_trusted_headers'] is \Symfony\Component\HttpFoundation\Request::HEADER_X_FORWARDED_ALL | \Symfony\Component\HttpFoundation\Request::HEADER_FORWARDED. This value is the most permissive and does not make much sense as reverse proxies do not use both "X-Forwarded-*" headers and "Forwarded" header. Therefore it is recommended to set a value when using reverse proxies.
The change was made for compatibility with Symfony 4. Use of the deprecated setting is not supported with Symfony 4.
Comments
A module to return `reverse_proxy_header` setting in Drupal 9-11
Here is a module Reverse Proxy Header to return `reverse_proxy_header` setting for your Drupal 9/10/11 instance.
This module is the simplest way to use the specific HTTP header name to retrieve the real client IP (from Cloudflare or any other proxy headers, etc).