Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS SSL on EC2 instance without Load Balancer - NodeJS

Tags:

Is it possible to have an EC2 instance running, listening on port 443, without a load balancer? I'm trying right now in my Node.JS app but it doesn't work when I call the page using https://. However, if I set it to port 80 everything works fine with http://.

I had it working earlier with a load balancer and route53, but I don't want to pay $18/mo for an ELB anymore, especially when I only have one server running.

Thanks for the help

like image 461
Thomas Avatar asked Nov 08 '16 05:11

Thomas


People also ask

Can I use ACM on EC2 instance?

Public ACM certificates can be installed on Amazon EC2 instances that are connected to a Nitro Enclave, but not to other Amazon EC2 instances.

How do I add an SSL to my EC2 instance?

There are three steps to install an SSL/TLS certificate on your EC2 Windows instance: Create a Certificate Signing Request (CSR) and request your SSL certificate. Install your SSL certificate. Assign the SSL certificate to your IIS deployment.

Do you need a load balancer for EC2?

If your application is built within the Amazon Elastic Compute Cloud (Amazon EC2) Classic network, you should use Classic Load Balancer. If you need to deploy and run third-party virtual appliances, you can use Gateway Load Balancer.


2 Answers

Is it possible? Yes of course. It sounds like you had an SSL certificate installed on the ELB and now you've deleted the ELB. You will have to install an SSL certificate on the EC2 server now. You can't use AWS ACM SSL certificates without an ELB or CloudFront distribution. If you don't want to pay for either of those services you will have to obtain an SSL certificate elsewhere.

like image 137
Mark B Avatar answered Sep 24 '22 21:09

Mark B


You're right, if it's only the one instance and you feel like you don't need to be prepared for large increases in traffic, you shouldn't have to pay for an ELB.

From a high-level standpoint you'll have to go through the following steps:

  1. Install an nginx server to serve your NodeJS application.
  2. Install your SSL certificates on the nginx server.

    -- Either do this manually, ssh'ing into the server and installing the certs as described here.

    -- OR include the necessary files in your application (I believe this only works for elastic beanstalk?) which will overwrite the nginx configuration files automatically as described here.

  3. Make sure nginx is listening on port 443 (should've been completed in the previous step)
  4. Open the EC2 server's security group corresponding to where you want traffic to enter the server (port 80 / port 443)
like image 22
Tom Nijs Avatar answered Sep 24 '22 21:09

Tom Nijs