Problem/Motivation
Settings for reverse proxy are not used in standard request.
Taking a look at the code, I've seen that the class ReverseProxyMiddleware
is used to read the reverse proxy settings and to apply them.
But this class is only used once in install.core.inc:426
.
During the normal request handling process, through index.php
, the class is never called and the settings are not used.
This results in Drupal ignoring the reverse proxy settings and generate wrong urls.
Consider this example architecture:
When I create a new user on the website, the e-mail sent to notify him about his new account has the wrong base url (http://web.drupal.loc). The same happens for other absolute urls, as for example the reset link, etc..
Proposed resolution
In DrupalKernel
class, when handling the request and after the settings inizialization, it must be called ReverseProxyMiddleware::setSettingsOnRequest
to read and apply the reverse proxy configuration (if present).
A proposed patch is attached.
Further notes
If it could be useful, to replicate the problem and test the solution I've set up a docker environment with a fresh drupal installation that I can share.