Skip to content

Instantly share code, notes, and snippets.

@klaasvw
Created October 10, 2012 06:31
Show Gist options
  • Save klaasvw/3863495 to your computer and use it in GitHub Desktop.
Save klaasvw/3863495 to your computer and use it in GitHub Desktop.
Drupal behind a proxy
/**
* @file
* This snippet shows how you can run drupal from a different host behind a proxy.
* Include this code at the bottom of your settings.php file.
*/
// Set the hosts that are allowed to be proxied to this drupal installation.
$conf['reverse_proxy_addresses'] = array('example.com', 'example2.com');
// If the request was proxied from a different domain we change the internal URL.
if (isset($_SERVER['HTTP_X_FORWARDED_HOST']) && in_array($_SERVER['HTTP_X_FORWARDED_HOST'], $conf['reverse_proxy_addresses'])) {
$base_url = 'http://' . $_SERVER['HTTP_X_FORWARDED_HOST'];
$conf['reverse_proxy'] = TRUE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment