Skip to content

Instantly share code, notes, and snippets.

@johnny-aroza
Last active January 18, 2021 03:23
Show Gist options
  • Select an option

  • Save johnny-aroza/cde58498c57fcb7b747ad4a7ca9d114a to your computer and use it in GitHub Desktop.

Select an option

Save johnny-aroza/cde58498c57fcb7b747ad4a7ca9d114a to your computer and use it in GitHub Desktop.
Drupal 8 reverse proxy drama

If the environment is using load balancer or reverse proxy / keubernates pod / cloudflare your reading the right gist

As drupal as has removed hard coding the base url from the settings.php

add followig in settings.php

// add trusted patterns 
$settings['trusted_host_patterns'] = [
  '^dg8\.test\.dev$',
  '^10\.100\.3\.255$',
  '^dgd8\.lndo\.site$'
];
//enable reverse proxy 
$settings['reverse_proxy'] = TRUE;
//Add list allowed load balacer ip or pass respective header
$settings['reverse_proxy_addresses'] = array($_SERVER['REMOTE_ADDR']);
//make sure pass the header holding the base url
$settings['reverse_proxy_host_header'] = 'X-ORIGINAL-HOST'; 

reference / Credits :

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment