Posts

Showing posts from July, 2024

AWS - Understanding Security Group

Image
  In this post will go in detail on a simple ALB to EC2 setup. I am configuring NodeJS on my EC2 instance. [root@ip-172-31-9-46 ~]# yum install npm [root@ip-172-31-9-46 ~]# npm install express Starting the application using the below command. [root@ip-172-31-9-46 ~]# node app.js App1 is listening on port 3000 App2 is listening on port 4000 Now, I configured a target group: In the target group we must give the application port and health check port . NOTE: We cannot mention any security group under Target group. Next, I am going to create a ALB. Our ALB listens on port 80. So the ABL DNS/welcome should route the traffic to backend machine. Eg: http:// demo-alb-123456.us-east-1.elb.amazonaws.com/welcome Now, our EC2 instance at the backend should accept traffic from ALB on port 3000/4000. Even though ALB has an IP address range which is dynamic, so create a security group based on IP is not the right solution. Hence, we will create a security group and attach to ALB. This ...

AWS - ALB HTTP Customization

Image
  One of the advantages of ALB which operates on layer 7 is the ability to make customization on the HTTP layer. Let see with some examples. I have a ALB with target group serving HTTP traffic. Let’s start with adding a rule to the ALB listener. Give the rule name. Add the condition.  I am adding a “Path” based condition. If someone access by ALB DNS name with /login -> http://demo-lb-571503325.us-east-1.elb.amazonaws.com/login then what should I do? For every condition we can selection 1 action from 3 actions. Since I did not configure anything on /login. I am going to return with a fixed response like “HTTP 500 – No login method configured”. Let’s test it.