From 3f882b112e39956191a56f64fe5cf4f5a1ff3770 Mon Sep 17 00:00:00 2001
From: Jesus Federico <jesus@123it.ca>
Date: Wed, 10 Dec 2014 11:31:38 -0500
Subject: [PATCH] bbb-lti: Fixed issue that prevented https to work on
 nginx/tomcat

---
 .../org/bigbluebutton/ToolController.groovy      | 16 +++++++++++++++-
 bbb-lti/lti.nginx                                |  1 +
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/bbb-lti/grails-app/controllers/org/bigbluebutton/ToolController.groovy b/bbb-lti/grails-app/controllers/org/bigbluebutton/ToolController.groovy
index 00d380cceb..0e0ae92d6d 100644
--- a/bbb-lti/grails-app/controllers/org/bigbluebutton/ToolController.groovy
+++ b/bbb-lti/grails-app/controllers/org/bigbluebutton/ToolController.groovy
@@ -54,7 +54,7 @@ class ToolController {
         ltiService.logParameters(params)
 
         if( request.post ){
-            def endPoint = (request.isSecure()?"https":"http") + "://" + ltiService.endPoint + "/" + grailsApplication.metadata['app.name'] + "/" + params.get("controller") + (params.get("format") != null? "." + params.get("format"): "")
+            def endPoint = getScheme() + "://" + ltiService.endPoint + "/" + grailsApplication.metadata['app.name'] + "/" + params.get("controller") + (params.get("format") != null? "." + params.get("format"): "")
             Map<String, String> result = new HashMap<String, String>()
             ArrayList<String> missingParams = new ArrayList<String>()
 
@@ -398,4 +398,18 @@ class ToolController {
 
         return cartridge
     }
+
+    private String getScheme(){
+        def scheme
+        if ( request.isSecure() ) {
+            scheme = 'https'
+        } else {
+            scheme = request.getHeader("scheme")
+            if ( scheme == null || !(scheme == 'http' || scheme == 'https') ) {
+                scheme = 'http'
+            }
+        }
+
+        return scheme
+    }
 }
diff --git a/bbb-lti/lti.nginx b/bbb-lti/lti.nginx
index 07a4130779..62a83d64ee 100644
--- a/bbb-lti/lti.nginx
+++ b/bbb-lti/lti.nginx
@@ -4,6 +4,7 @@
            proxy_pass         http://127.0.0.1:8080;
            proxy_redirect     default;
            proxy_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;
+           proxy_set_header   Scheme $scheme;
 
 	# Allow 30M uploaded presentation document.
            client_max_body_size       30m;
-- 
GitLab