【问题标题】:Node.js and Docker- Elastic Beanstalk 502 Bad GatewayNode.js 和 Docker - Elastic Beanstalk 502 错误网关
【发布时间】:2019-07-07 17:49:04
【问题描述】:
sslSecurityGroupIngress: 
  Type: AWS::EC2::SecurityGroupIngress
  Properties:
    GroupId: {"Fn::GetAtt" : ["AWSEBSecurityGroup", "GroupId"]}
    IpProtocol: tcp
    ToPort: 443
    FromPort: 443
    CidrIp: 0.0.0.0/0

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

【问题讨论】:

  • 如何access the app at the instance level?再次检查端口,如果节点在实例上的端口 443 上运行,而不是在容器中。 502是最服务器端错误,
  • 使用 EC2 实例控制台中的公共 dns 链接
  • @AbdullahFarooq,您找到解决方案了吗?我遇到了同样的问题,似乎没有人知道答案,因为我的帖子也没有得到答复。

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


【解决方案1】:

我能够看到我的应用程序被配置为在端口 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 ===============

【讨论】:

    猜你喜欢
    • 2015-04-27
    • 2022-07-01
    • 2022-01-12
    • 2019-06-12
    • 2019-07-03
    • 2017-12-09
    • 2015-05-04
    • 1970-01-01
    • 2021-09-16
    相关资源
    最近更新 更多