Path settings is not working behind a reverse proxy

Created on 16 May 2024, 7 months ago

Problem/Motivation

The exclude/include path functionality is working well except the Drupal site is hosted behind a reverse proxy.

Steps to reproduce

  1. Enable shield.
  2. Set the user name and password for shield to make it work.
  3. In the 'Path' setting, chose 'Include' for the 'Path Method'.
  4. Set '/user' and '/user/login' in seperate line to include the user login path in the shield protection.
  5. Save the setting above.

Expected result:

The user login page is protected by the shield.

Actual result:

Those pages are not protected, if the Drupal site is sitting behind a reverse proxy.

Proposed resolution

Drupal core provides the Drupal\Core\StackMiddleware\ReverseProxyMiddleware to deal with reverse proxy for a StackPHP middleware implementation.
Details See https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21StackMidd...

Shield module can use the ReverseProxyMiddleware::setSettingsOnRequest() function to address this issue, similar to what the core does.
For example, at line 431 in install.core.inc file.
https://git.drupalcode.org/project/drupal/-/blob/11.0.x/core/includes/in...

In order to make the Drupal reverse proxy setting work, you have to set reverse_proxy to TRUE.
Details on how to configuration a Drupal site for that see
https://www.drupal.org/docs/getting-started/installing-drupal/using-a-lo...

User interface changes

N/A

API changes

N/A

Data model changes

N/A

🐛 Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

🇦🇺Australia mingsong 🇦🇺

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024