4
votes
sslSecurityGroupIngress: 
  Type: AWS::EC2::SecurityGroupIngress
  Properties:
    GroupId: {"Fn::GetAtt" : ["AWSEBSecurityGroup", "GroupId"]}
    IpProtocol: tcp
    ToPort: 443
    FromPort: 443
    CidrIp: 0.0.0.0/0

In Nginx I have already increased proxy_connect_timeout and proxy_read_timeout

1
How to access the app at the instance level? Check the port again, if the node running on port 443 on the instance, not in container. 502 is most the server side error, - BMW
Using the public dns link in the EC2 instance console - Abdullah Farooq
@AbdullahFarooq, have you found a solution? I am having the same problem and no one seems to know the answer as my post as gone unanswered as well. - Daniel

1 Answers

1
votes

I was able to see that my Application was configured to listen at both ports 80 and 443, although the rules were only redirecting for the port 80 of the instance, even if the request comes from the https protocol. If you would like to configure a End-to-End https, it will be necessary a rule redirecting to the port 443 of the instances.

Previously my Elastic Beanstalk configuration was set like:

Listener      Rules         Process

443             443            default
80              80             default 

Where the "default" process is redirecting all connections through the port 80 of the instances.

I updated my ElasticBeanstalk Environment to forward the https requests to the port 443 of the instance? Below is an example on how associate the rule with the process:

======== .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 ========

One circumstance that could be causing this issue may be related to your application only listening at the 443 port, once none of the rules of the ALB redirect for this port at the instance, it is reasonable that the access is failing with a Bad Gateway request.

Add this for http to https redirection:

============= 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 ===============