diff --git a/youtube.theme.inc b/youtube.theme.inc
index 803ba1c..71f3578 100644
--- a/youtube.theme.inc
+++ b/youtube.theme.inc
@@ -33,7 +33,7 @@ function theme_youtube_video($variables) {
   $dimensions = youtube_get_dimensions($size, $width, $height);
 
   // Protocol changes based on current page TODO.
-  $protocol = (isset($_SERVER['HTTPS'])) ? 'https' : 'http';
+  $protocol = (isset($_SERVER['HTTPS']) || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') ? 'https' : 'http';
 
   // Query string changes based on setings.
   $query = array();
