AWS SSL on EC2 instance without Load Balancer - NodeJS

孤者浪人 提交于 2021-02-06 08:39:39

问题


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


回答1:


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)



回答2:


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.




回答3:


For our projects (much like the other poster described) we used this setup:

  1. nginx as load balancer and proxy for all calls on port 80 (no direct call to node.js server on port 3000 which is closed to the public)
  2. pm2 as process manager for Node.js (and for deployment)
  3. keymetrics.io for monitoring
  4. Nodejs v6.9.3 boron/lts (through NVM)
  5. Mongodb 3.2 with WiredTiger Engine (Compose.io)
  6. Amazon EC2 instances for hosting (Amazon Linux not Ubuntu)

This setup works very well for us. And in this setup we're able to setup SSL without using the amazon load balancers.



来源:https://stackoverflow.com/questions/40479534/aws-ssl-on-ec2-instance-without-load-balancer-nodejs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!