3 Answers
- Newest
- Most votes
- Most comments
1
Hello.
It is possible to redirect to HTTPS with ALB.
To create an HTTPS listener with ALB, you will also need to issue a certificate with ACM, but you will no longer need to configure HTTPS with Nginx.
https://repost.aws/knowledge-center/elb-redirect-http-to-https-using-alb
An example setting for CloudFormation is as follows.
ALB:
Type: "AWS::ElasticLoadBalancingV2::LoadBalancer"
Properties:
Name: !Sub ${ServerName}-alb
Scheme: "internet-facing"
LoadBalancerAttributes:
- Key: "deletion_protection.enabled"
Value: false
- Key: "idle_timeout.timeout_seconds"
Value: 4000
SecurityGroups:
- !Ref SGloadbalancer
Subnets:
- !Ref Subnet1
- !Ref Subnet2
ALBListenerHTTP:
Type: "AWS::ElasticLoadBalancingV2::Listener"
Properties:
Port: 80
Protocol: HTTP
DefaultActions:
- Type: redirect
RedirectConfig:
Host: '#{host}'
Path: '/#{path}'
Port: 443
Protocol: HTTPS
Query: '#{query}'
StatusCode: HTTP_301
LoadBalancerArn: !Ref ALB
ALBListenerHTTPS:
Type: AWS::ElasticLoadBalancingV2::Listener
Properties:
Port: 443
Protocol: HTTPS
Certificates:
- CertificateArn: !Ref ACM
DefaultActions:
- TargetGroupArn: !Ref TargetGroup
Type: forward
LoadBalancerArn: !Ref ALB
0
The ALB can redirect from HTTP to HTTPS, but you're looking for something else?
0
CloudFront natively supports redirects from HTTP to HTTPS. For more complex interactions, you could also use Lambda@Edge: https://aws.amazon.com/blogs/networking-and-content-delivery/handling-redirectsedge-part1/
Relevant content
- asked a year ago
- asked 2 years ago
- AWS OFFICIALUpdated a month ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 days ago
- AWS OFFICIALUpdated 2 months ago