简体   繁体   中英

Running node.js app on aws ec2 instance with https

I uploaded my node.js app with ec2 AWS instance, my app.ts running on port 5000, I allowed within inbound rules HTTPS on port 443, also I bought have a domain with route 53 amazon, when I'm trying to send a request to https://ec2-3-example.com am getting err connection refused but when I'm sending a request with http://ec2-3-example.com:5000 locally I get the data from the server, how do I solve this? thanks in advance I can share the code if it helps

In order to have access to your app via HTTPS, you will have to attach an SSL certificate to a reverse proxy somewhere in the middle of the system.

The problem you are experiencing is that you are opening port 443 in the EC2 instance, but your application is running on port 5000 . On top of that, SSL termination will not be done automatically. You will need a reverse proxy like ALB or Nginx.

One way of doing it in your case could be:

  • Check that your app runs on port 5000 in an EC2 instance
  • Create an ALB and add your EC2 instance to it
  • Attach an SSL Certificate to your ALB with the corresponding domain
  • Allow inbound traffic on port 5000 in the security group of your EC2 instance, from your ALB
  • Allow inbound traffic on port 443 for the ALB
  • Route traffic from your domain on Route53 to your ALB

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM