This document will provide detailed instructions and a step-by-step process to setup and configure a WAF for AWS using a Virtual Private Cloud (VPC) and an Application Load Balancer (ALB).

Configuring AWS WAF with an ALB in a VPC

Phase 1: Prerequisites in your VPC

  1. Ensure your VPC is configured: You need a VPC with at least two public subnets (for an internet-facing ALB) and private subnets (for your application servers).
  2. Deploy your Application: Host your application on EC2, ECS, or EKS within the private subnets.
  3. Create an Application Load Balancer (ALB):

Phase 2: Creating and Configuring the AWS WAF Web ACL

  1. Open the AWS WAF Console: Navigate to WAF & Shield in the AWS Management Console.
  2. Create a Web ACL:
  3. Associate AWS resources:
  4. Add Rules and Rule Groups:
  5. Set Default Action:
  6. Set Rule Priority:
  7. Configure Metrics and Logging:

Phase 3: Testing and Deployment

  1. Start in "Count" Mode: When you first add rules (especially Managed Rules), set their action to Count instead of Block. This allows you to review the logs to ensure legitimate traffic isn't being blocked (false positives).
  2. Review Logs: Monitor the WAF logs via CloudWatch or Athena (if using S3).
  3. Switch to "Block": Once you are confident the rules are only catching malicious traffic, edit the Web ACL and change the rule actions from Count to Block.