frame

How to Open a Port other than port 80 and 22 on Amazon EC2

edited July 6 in Hosting

If you have ever hosted a microservices based application on EC2, you often find you have to serve different content on different ports. The problem though is that amazon ec2 does not allow incoming traffic to ports other than port 80 and 22 by default. This short post, is a reminder to myself and anyone else whom might encounter this scenario, on how to quickly get past this issue.

Step 1 : on your ec2 instances console, select the instance in question

Step 2: on the right hand side, navigate to networking -> securty groups.

Step 3: create a new security group.

Step 4 Select your new security group, then create a new rule. Name it whatever you like, but set incoming address to 0.0.0.0/0. Fill in the desired port in the port column

Step 2: Go back to instance console, then right click on your instance, then -> network settings -> apply security groups and choose your newly created security gruop.

Step 5: your application should be available publicly now via the opened port, but if its not, make sure your app serving is serving with 0.0.0.0:PORT. and not localhost:PORT. This mistake is easy to make if you are using laravel, and using the command php -S localhost:port -t public to serve your app.

Cheers!

Comments

  • This came in quite timely for I am about to do another stuff like this after a long time, and I have gotten a bit rusty at the edges too. Thanks

  • @dhtml said:
    This came in quite timely for I am about to do another stuff like this after a long time, and I have gotten a bit rusty at the edges too. Thanks

    You are welcome, baba.

  • That's good. If I have seen this an hour ago I could have saved 10 minutes.
    For the first time, I was setting up and application on ec2. and decide to try out with Drupal my fav CMF

Sign In or Register to comment.

Africoders

© Africoders 2014 - 2019, All rights reserved. You will also find Africoders on FreeBasics.

Get In Touch