How can I redirect HTTP requests to HTTPS using an Application Load Balancer?
I want to redirect HTTP requests to HTTPS using Application Load Balancer listener rules. How can I do this?
"I want to redirect HTTP requests to HTTPS using Application Load Balancer listener rules. How can I do this?ResolutionConfirm your version of Load BalancerOpen the Amazon Elastic Compute Cloud (Amazon EC2) console.Under Load Balancing in the sidebar, choose Load Balancers.Find the load balancer for which you're creating a listener rule. Note which version is listed under the Type column: application, classic, network, or gateway.The following steps apply only to Application Load Balancer. If you're using Classic Load Balancer, then see How do I redirect HTTP traffic to HTTPS on my Classic Load Balancer?Note: You must create a target group before following the steps below.Create an HTTP listener rule that redirects HTTP requests to HTTPSOpen the Amazon EC2 console.Under Load Balancing in the sidebar, choose Load Balancers.Select a load balancer, and then choose Listeners, Add listener. Note: Skip to step 6 if you already have an HTTP listener.For Protocol: port, choose HTTP. You can either keep the default port or specify a custom port.For Default actions, choose Add action, redirect to, and then enter port 443 (or a different port if you’re not using the default). For more details, see Rule action types. To save, choose the checkmark icon. Note: If you created a new HTTP listener following steps 3-5 in this set of tasks, skip to Create an HTTPS listener.Select a load balancer, and then choose HTTP Listener.Under Rules, choose View/edit rules.Choose Edit Rule to modify the existing default rule to redirect all HTTP requests to HTTPS. Or, insert a rule between the existing rules (if appropriate for your use case).Under Then, delete the existing condition. Then, add the new condition with the Redirect to action.For HTTPS, enter 443 port.Keep the default for the remaining options.Note: If you want to change the URL or return code, you can modify these options as needed.To save, choose the checkmark icon.Create an HTTPS listenerNote: If you already have an HTTPS listener with a rule to forward requests to the respective target group, skip to Verify that the security group of the Application Load Balancer allows traffic on 443.Choose Listeners, Add listener.For Protocol: port, choose HTTPS. Keep the default port or specify a custom port.For Default actions, choose Add action, Forward to.Select a target group that hosts application instances.Select a predefined security policy that's best suited for your configuration.Choose Default Security Certificate. (If you don’t have one, you can create a security certificate.)Choose Save.Verify that the security group of the Application Load Balancer allows traffic on 443Choose the load balancer's Description.Under Security, choose Security group ID.Verify the inbound rules. The security group must have an inbound rule that permits traffic on HTTP and HTTPS. If there are no inbound rules, complete the following steps to add them.To add inbound rules (if you don't already have them):Choose Actions, Edit Inbound Rules to modify the security group.Choose Add rule.For Type, choose HTTPS.For Source, choose Custom (0.0.0.0/0 or Source CIDR).Choose Save.Follow"