AWS – Web Application Firewall (WAF)
Step 1: Create 2 EC2 instances in different AZs and install httpd and update the index.html file under /var/www/html folder so that you can differentiate these 2 instances’ webservers.
Step 2: Create Application LB by creating a single Target Group by registering both instances.
Step 3: Get your public IP address so that we can restrict to access ALB from the system.
Step 4: Goto WAF—> IPSets
Step 5 Set following Configuration
IP Set Name: MyIPSet
Region: Select your region
Add Your IP Address in IP addresses.like 27.7.187.246/32
Click on Create IP Set
Step 6: Select Web ACL –> Click on Create WebACL
Step 7: Provide the details like
Name: MyWebAcl
Click on Add AWS resources button and select your ALB
Click on Next Button
Step 8: Add Rule by click on Add Rule–> Select my own rule.
Step 9: Select IP Set and select your IP Select and click on Block access
Step 10: Reset of the options no change and Create on WebACL button.
Try to access your ALB on web it should be forbidden