AWS ELB 将 HTTP 重定向到 HTTPS

AWS ELB redirect HTTP to HTTPS

我正在使用此 CloudFormation 模板 https://github.com/widdix/aws-cf-templates/blob/master/jenkins/jenkins2-ha-agents.yaml 来设置 jenkins 服务器。

我现在想向 ELB 添加 SSL,并已将 https://github.com/widdix/aws-cf-templates/blob/master/jenkins/jenkins2-ha-agents.yaml#L511-L519 修改为以下内容:

  MasterELBListener:
    Type: AWS::ElasticLoadBalancingV2::Listener
    Properties:
      DefaultActions:
        - Type: "redirect"
          RedirectConfig:
            Protocol: "HTTPS"
            Port: "443"
            Host: "#{host}"
            Path: "/#{path}"
            Query: "#{query}"
            StatusCode: "HTTP_301"
      LoadBalancerArn: !Ref MasterELB
      Port: 80
      Protocol: HTTP

  MasterHTTPSListener:
    Type: AWS::ElasticLoadBalancingV2::Listener
    Properties:
      Certificates:
        # - CertificateArn: !Ref CertificateARN
        - CertificateArn: !FindInMap
            - SSLmapping
            - ssl1
            - !FindInMap
              - AWSRegionsNameMapping
              - !Ref 'AWS::Region'
              - RegionName
      DefaultActions:
      - Type: forward
        TargetGroupArn: !Ref MasterELBTargetGroup
      LoadBalancerArn: !Ref MasterELB
      Port: 443
      Protocol: HTTPS

但是当我尝试访问该站点时,它只是时间。

非常感谢任何建议

好的,我需要从 ELB 打开对 433 的访问权限,方法是:

  MasterELBHTTPSSGInWorld:
    Type: 'AWS::EC2::SecurityGroupIngress'
    Condition: HasNotAuthProxySecurityGroup
    Properties:
      GroupId: !Ref MasterELBSG
      IpProtocol: tcp
      FromPort: 443
      ToPort: 443
      CidrIp: '0.0.0.0/0'