How to do SSL termination using AWS Application Load Balancer for Express REST API

amazon ec2httpsload balancingreverse-proxy

I have a Node Express server running on an EC2 instance that listens for HTTP requests. I want to use an AWS Application Load Balancer to serve that content to the client browser through HTTPS while talking to my EC2 instance through HTTP (rather than make an HTTPS express server — as recommended in the last EDIT TO ADD of this post)

Browser — HTTPS Request –> AWS ELB — HTTP Request –> EC2

How can I accomplish that? Tried to set a redirect to the EC2 instance but the console doesn't redirect from HTTPS -> HTTP

Best Answer

Try the following setup:

  1. Create an Application Load Balancer with a Listener set to HTTPS listening on port 443.
    • Use availability zones that are public.
    • Use a certificate from ACM.
  2. Under "Configure Routing", create a target group with Target type "instance", Protocol HTTP, Port 3000. Make sure your health check path actually resolves on your instance.
  3. Under Register Targets, add your target instance but make sure to specify the port as 3000 and click the "Add to registered" button or it won't actually do anything.
  4. After creating the Application Load Balancer, create a DNS entry using a CNAME and Alias to "Yes" and specify your newly created Load Balancer.
  5. Once your DNS entry is created, test your new load balancer. If it fails, check the following.
    • Make sure the listener healthcheck is not failing. If it's failing, make sure your ec2 instance is allowing traffic from the load balancer in your security group.