繁体   English   中英

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

[英]Node.js and Docker- Elastic Beanstalk 502 Bad Gateway

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

尽管规则仅重定向实例的端口80,即使请求来自https协议,我仍然可以看到我的应用程序已配置为同时监听端口80和443。 如果要配置端到端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 ===============

暂无
暂无

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

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