How can I redirect HTTP requests to HTTPS using an Application Load Balancer?

Share This:
AWS ELB

I want to redirect HTTP requests to HTTPS using Application Load Balancer listener rules. How can I do this?

Resolution

Create an HTTP listener rule that redirects HTTP requests to HTTPS

  1. Open the Amazon Elastic Compute Cloud (Amazon EC2) console.
  2. On the navigation pane, under LOAD BALANCING, choose Load Balancers.
  3. Select a load balancer, and then choose ListenersAdd listener.
    Note: Skip to step 6 if you already have an HTTP listener.
  4. For Protocol: port, choose HTTP. You can either keep the default port or specify a custom port.
  5. For Default actions, choose Add actionredirect 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 above, skip to Create an HTTPS listener.
  6. Select a load balancer, and then choose HTTP Listener.
  7. 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).
  8. Under Then, delete the existing condition and add the new condition with the Redirect to action.
    For HTTPS, enter 443 port and keep the default for the remaining options.
    To save, choose the checkmark icon.
    Note: If you want to change the URL or return code, you can modify these options as needed.

Create an HTTPS listener

Note: If you already have an HTTPS listener with a rule to forward requests to the respective target group, skip to Verify that the Application Load Balancer’s security group allows traffic on 443.

  1. Choose ListenersAdd listener.
    For Protocol: port, choose HTTPS. You can either keep the default port or specify a custom port.
  2. For Default actions, choose Add actionForward to. Then, choose a target group that hosts application instances.
    Choose one of the predefined security policies or choose the best one 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 443

  1. Choose the load balancer’s Description.
  2. Under Security, choose Security group ID.
  3. Verify the inbound rules. The security group should have an inbound rule that permits traffic on HTTP and HTTPS. If there are no inbound rules:
    Choose ActionsEdit 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.
AWS ELB
Share This:

Popular on WPSteam Right Now!

Leave a Reply

Your email address will not be published. Required fields are marked *

I need help with...