简体   繁体   English

Canvas LTI 适用于 AWS 开发,但在生产中返回无效的消费者密钥(负载均衡器)

[英]Canvas LTI works on AWS dev but returns Invalid consumer key on production (Load balancer)

I am implementing a basic canvas LTI from a client to our AWS EC2.我正在从客户端到我们的 AWS EC2 实施基本的画布 LTI。 It works fine when the endpoint is our dev EC2.当端点是我们的开发 EC2 时,它工作正常。 However, when the endpoint is our live site, in which the EC2s are behind a load balancer, it fails with "Invalid consumer key"但是,当端点是我们的实时站点时,其中 EC2 位于负载均衡器之后,它会失败并显示“消费者密钥无效”

The base code is exactly the same and the EC2s are all from the same AMI.基本代码完全相同,EC2 都来自同一个 AMI。

Any ideas are appreciated!任何想法表示赞赏!

The issue is that the aws load balancer was connecting to the EC2 targets via http port 80 and this was causing oauth to fail.问题是 aws 负载均衡器通过 http 端口 80 连接到 EC2 目标,这导致 oauth 失败。

I am not sure how changing/adding https/443 to the Target groups will affect my autoscaling group and health checks etc, so I edited the OAuth.php file, removing the part in the from_request function that checks if the server is https because we'll always be connecting via https for this.我不确定将 https/443 更改/添加到目标组会如何影响我的自动缩放组和健康检查等,因此我编辑了 OAuth.php 文件,删除了 from_request 函数中检查服务器是否为 https 的部分,因为我们为此,将始终通过 https 进行连接。

Changed this:改变了这一点:

public static function from_request($http_method=NULL, $http_url=NULL, $parameters=NULL) {
    $scheme = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on")
              ? 'http'
              : 'https';
    $http_url = ($http_url) ? $http_url : $scheme .
                              '://' . $_SERVER['SERVER_NAME'] .
                              ':' .
                              $_SERVER['SERVER_PORT'] .
                              $_SERVER['REQUEST_URI'];

To this:对此:

 public static function from_request($http_method=NULL, $http_url=NULL, $parameters=NULL) {        
        $scheme = 'https';
        $http_url = ($http_url) ? $http_url : $scheme .
            '://' . $_SERVER['SERVER_NAME'] .
            ':' .
            443 .
            $_SERVER['REQUEST_URI'];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM