Node.js和Docker- Elastic Beanstalk 502错误网关

时间:2019-02-13 19:24:11

标签: node.js docker terraform amazon-elastic-beanstalk

index

在Nginx中,我已经增加了proxy_connect_timeout和proxy_read_timeout

1 个答案:

答案 0 :(得分:0)

我能够看到我的应用程序被配置为同时侦听端口80和443,即使规则仅重定向实例的端口80,即使请求来自https协议也是如此。如果要配置端到端https,则必须将规则重定向到实例的端口443。

以前,我的Elastic Beanstalk配置设置为:

Listener      Rules         Process

443             443            default
80              80             default 

“默认”进程通过实例的端口80重定向所有连接的位置。

我更新了ElasticBeanstalk环境以将https请求转发到实例的端口443?以下是有关如何将规则与流程关联的示例:

======== .ebextensions/https-reencrypt-alb.config ========
option_settings:
  aws:elbv2:listener:443:
    DefaultProcess: https
    ListenerEnabled: 'true'
    Protocol: HTTPS
  aws:elasticbeanstalk:environment:process:https:
    Port: '443'
    Protocol: HTTPS
======== .ebextensions/https-reencrypt-alb.config ========

可能导致此问题的一种情况可能与您的应用程序仅在443端口上侦听有关,一旦实例中该端口的ALB规则均未重定向,则访问失败是合理的。错误的网关请求。

将此添加到http到https重定向:

============= http-to-https.config ===============
Resources:
  AWSEBV2LoadBalancerListener:
    Type: AWS::ElasticLoadBalancingV2::Listener
    Properties:
      DefaultActions:
        - Type: redirect
          RedirectConfig:
            Protocol: HTTPS
            Port: 443
            StatusCode: 'HTTP_301'
      LoadBalancerArn:
        Ref: AWSEBV2LoadBalancer
      Port: 80
      Protocol: HTTP
============= http-to-https.config ===============
相关问题