Have you ever imagined!
While working on a project, you have deployed an application and, for testing purposes, you want to expose this application for testing or build processes. Then, you will use Docker or Kubernetes to deploy and secure your application. After exposing the port, you try to access it on your browser. At the end, you realize that you are not able to access it.
THAT'S THE PROBLEM >>> SOLUTION
This is happening because you have not defined the inbound and outbound rules in your EC2 virtual server, which means you have not opened ports for your application. To do that, you have to define the inbound and outbound rules for your EC2 instance.
What are Security Groups?
Security Groups can be considered as traffic controllers for your EC2 instance, which decide what goes in and what goes out. They define the inbound and outbound traffic rules for your EC2 instance.
Here is an example of an inbound rule for SSH (port 22):
Type: SSH
Protocol: TCP
Port Range: 22
Source: 203.0.113.0/24
What are Network ACLs?
Network Access Control Lists act on your VPC (Virtual Private Cloud). They control all the firewalls at the VPC level. If you want to allow some traffic to your application, you can define the inbound and outbound rules at the VPC level.
Here is an example that allows inbound traffic for HTTP (port 80):
Rule #: 100
Type: Inbound
Protocol: TCP
Port Range: 80
Source: 203.0.113.0/24
Allow/Deny: ALLOW
I hope you liked it! :)