Search code examples
amazon-web-servicesamazon-ec2httpsamazon-route53amazon-elb

AWS Aplication Load Balancer HTTP to HTTPS with EC2 instance


I have a EC2 instance running a Node.Js server on Ubuntu.

My goals are:

  1. Connect my hosted zone to the EC2 instance
  2. Route all incoming traffic from port 80 to port 3000 (because my server runs on port 3000)
  3. and most importantly Use an Application Load Balancer to forward all requests to HTTPS (I already created a SSL Certificate in the Certificate Manager).

Currently, I am only able to open the website with the EC2 intances' Public Ip on port 3000 (http://prntscr.com/livali). Https requests or Http to port 80 don't work (http://prntscr.com/livau2). Altought a made an A record on my hosted zone with the instances' Public Ip, it's not possible to open the instance via the hosted zone (http://prntscr.com/liv9no).

I am really confused, as I am somehow not able to get this up and running. I would really appreciate a step by step guide on how to set this whole thing up.


Solution

  • If you already have a SSL certificate it is secure to use only port 443 instead of port 80.

    1. Create an internet facing Application Load Balancer that listens on port 443 and routes traffic to your EC2 instance on port 3000.

    2. Redirect users to HTTPS when accessing your domain on HTTP

      See Docs > Load Balancer Listeners > Redirect Actions

    3. Add an A record to point your domain name to the Load Balancer's public DNS.