2

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.

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

2 Comments

How do I associate the Application Load Balancer with my EC2 instance?
You can add it as a target group. Check the AWS documentation. Pretty straightforward.
0

These are web server concerns rather than DNS concerns. You'll need to set up something like NGINX or Apache to proxy port 80 to port 3000. See Apache redirect to another port for information.

You can also force HTTPS with a rewrite rule in Apache: https://wiki.apache.org/httpd/RewriteHTTPToHTTPS

Another option for forcing HTTPS is to create a CloudFront distribution and use that. https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-https.html

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.