John Doe John Doe - 1 month ago 16
Linux Question

How to open a port for http traffic on ec2 from node app?

So I have an ec2 instance running a node app on port 3000, very typical setup. However I now need to run additional apps on this server, which currently are running on their own servers, also on port 3000. So I need to migrate them all to one server, and presumably run them on different ports.

So if I want to run node apps and have them on 3000, 3010, 3020, etc, how do I do this the right way?

Answer

You need to authorize inbound traffic to your ec2 instance via AWS Console, or API. Here is a good description how to do that :

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/authorizing-access-to-an-instance.html

Since authorizing is normally a one off, probably better to do it through the AWS Console, however, if one of your requirements is to spin up node apps in different ports in an automated fashion, then you'll probably want to look at this:

http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/EC2.html#authorizeSecurityGroupIngress-property