DrupalStand / drupal-dev-docker

An opinionated Drupal development environment based on Docker.
GNU General Public License v2.0
22 stars 19 forks source link

Forcing HTTPS behind TLS termination for Drupal 8/9 #63

Open stevenlafl opened 3 years ago

stevenlafl commented 3 years ago

Alt title: How to force Drupal 8/9 to output HTTPS URLs when using an nginx reverse proxy


Insert into settings.php

$settings['reverse_proxy'] = TRUE;
$settings['reverse_proxy_addresses'] = array($_SERVER['REMOTE_ADDR']);

And forward appropriate headers with nginx config

proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-Port 443;

Or with apache in mod_headers.c section

RequestHeader set X-Forwarded-Proto https
RequestHeader set X-Forwarded-Port 443

Thanks @jeffbeagley

stevenlafl commented 3 years ago

Need to add to the README file. Task up for assignment.