Skip to content

Instantly share code, notes, and snippets.

@chales
Forked from mpezzi/elb.aws.settings.inc
Created June 27, 2014 16:49
Show Gist options
  • Save chales/fd8b51ed2aae5e4e1c85 to your computer and use it in GitHub Desktop.
Save chales/fd8b51ed2aae5e4e1c85 to your computer and use it in GitHub Desktop.
<?php
/**
* @file
* Amazon Elastic Load Balancer Settings.
*
* Force server to use https:// path if SSL is handled at load balancer.
*
* @see http://drupal.org/node/185161#comment-5452038
*/
// We're running HTTPS natively in the web server.
if ( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ) {
$base_root = 'https';
}
// We're behind a proxy that talks to the web server via HTTP.
elseif ( isset($_SERVER['HTTP_X_FORWARDED_PROTO']) ) {
$base_root = $_SERVER['HTTP_X_FORWARDED_PROTO'];
}
// There's no HTTPS spoor -- we must be running HTTP.
else {
$base_root = 'http';
}
$base_url = $base_root .= '://'. $_SERVER['HTTP_HOST'];
// $_SERVER['SCRIPT_NAME'] can, in contrast to $_SERVER['PHP_SELF'], not be modified by a visitor.
if ( $dir = trim(dirname($_SERVER['SCRIPT_NAME']), '\,/') ) {
$base_path = "/$dir";
$base_url .= $base_path;
$base_path .= '/';
}
else {
$base_path = '/';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment