diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index dc569b1647..f1fc6e34b0 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -730,6 +730,16 @@ function drupal_valid_http_host($host) {
  *   TRUE if the request is HTTPS, FALSE otherwise.
  */
 function drupal_is_https() {
+  // If Drupal is behind a reverse proxy or load balancer that is communicating
+  // with the end-user over https but with Drupal over http we check if
+  // $_SERVER['HTTP_X_FORWARDED_PROTO'] is set to 'https'.
+  if (variable_get('reverse_proxy', 0)) {
+    $reverse_proxy_proto_header = variable_get('reverse_proxy_proto_header', 'HTTP_X_FORWARDED_PROTO');
+    if (isset($_SERVER[$reverse_proxy_proto_header]) && strtolower($_SERVER[$reverse_proxy_proto_header]) == 'https') {
+      $_SERVER['HTTPS'] = 'on';
+    }
+  }
+
   return isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on';
 }
 
diff --git a/sites/default/default.settings.php b/sites/default/default.settings.php
index a152b287e9..bf32712120 100644
--- a/sites/default/default.settings.php
+++ b/sites/default/default.settings.php
@@ -406,10 +406,13 @@ ini_set('session.cookie_lifetime', 2000000);
  * specified in $conf['reverse_proxy_addresses'] to work correctly.
  *
  * Enable this setting to get Drupal to determine the client IP from
- * the X-Forwarded-For header (or $conf['reverse_proxy_header'] if set).
- * If you are unsure about this setting, do not have a reverse proxy,
- * or Drupal operates in a shared hosting environment, this setting
- * should remain commented out.
+ * the X-Forwarded-For header (or $conf['reverse_proxy_header'] if set), also
+ * enable this setting to get Drupal determine the protocol from the
+ * X-Forwarded-Proto (or $conf['reverse_proxy_proto_header'] if set).
+ *
+ * If you are unsure about this setting, do not have a reverse proxy or Drupal
+ * operates in a shared hosting environment, this setting should remain
+ * commented out.
  *
  * In order for this setting to be used you must specify every possible
  * reverse proxy IP address in $conf['reverse_proxy_addresses'].
@@ -433,6 +436,12 @@ ini_set('session.cookie_lifetime', 2000000);
  */
 # $conf['reverse_proxy_header'] = 'HTTP_X_CLUSTER_CLIENT_IP';
 
+/**
+ * Set this value if your proxy server or load balancer sends the client
+ * protocol in a header other than X-Forwarded-Proto.
+ */
+# $conf['reverse_proxy_proto_header'] = 'HTTP_X_FORWARDED_PROTO';
+
 /**
  * Page caching:
  *
