Drupal 6 load balancing with SSL/HTTPS

When load balancing with SSL/HTTPS certificate on the load balancer and having the load balancer send out a normal HTTP request to the computer cluster Drupal 6 does not always notice the HTTPS request since the $_SERVER['HTTPS'] is not set. So for instance a JQuery (AJAX / AHAH) call in autocomplete will still use HTTP and get blocked by the load balancer causing an error.

Analysing the $_SERVER variable you might find that $_SERVER['HTTP_X_FORWARDED_PROTO'] is set to "https". If so, a solution might be to hack the function conf_init() in /includes/bootstrap.inc and append a condition to existing " ... $_SERVER['HTTPS'] == 'on' ..."

Existing:

<?php
// Create base URL
   
$base_root = (isset($_SERVER['HTTPS']) &amp;&amp; $_SERVER['HTTPS'] == 'on') ? 'https' : 'http';
   
$base_url = $base_root .= '://'. $_SERVER['HTTP_HOST'];
?>

Modified:
<?php
// Create base URL
   
$base_root = ((isset($_SERVER['HTTPS']) &amp;&amp; $_SERVER['HTTPS'] == 'on') ||
    (isset(
$_SERVER['HTTP_X_FORWARDED_PROTO']) &amp;&amp; $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' )) ? 'https' : 'http';
   
$base_url = $base_root .= '://'. $_SERVER['HTTP_HOST'];
?>
Knowledge keywords: