Web Application Firewall (WAF): Complete Setup & Configuration Guide

918 views · likes · 12 shares
Share on
16 min read
Web Application Firewall (WAF): Complete Setup & Configuration Guide

Key Takeaways

  • A WAF (Web Application Firewall) protects against application-layer attacks: SQL injection, XSS, file inclusion, credential stuffing, and API abuse.
  • WAF operates at Layer 7 - it inspects HTTP/HTTPS request content, unlike traditional firewalls that only filter network packets.
  • Combine WAF with DDoS protection and bot management for comprehensive security, each addressing different attack layers.
  • Start with managed rulesets (OWASP CRS, Cloudflare Managed Rules) and add custom rules based on your application's specific attack patterns.
  • Monitor mode first: Deploy new WAF rules in log/monitor mode before blocking, false positives can break legitimate functionality.

Your website faces hundreds of automated attacks daily, SQL injection probes, XSS payloads, credential stuffing attempts, and exploit scanners. A Web Application Firewall (WAF) is the security layer that inspects every HTTP request, detects malicious patterns, and blocks attacks before they reach your application.

What Is a WAF?

A WAF sits between your web traffic and your application, analysing every HTTP/HTTPS request against a set of security rules. It's distinct from network firewalls (which filter by IP/port) and IDS/IPS systems (which monitor network packets). WAFs understand web protocols, they can inspect URL parameters, request bodies, cookies, headers, and file uploads for malicious content.

How a WAF Works

Positive Security Model (Allowlisting)

Defines what legitimate requests look like and blocks everything else. Most secure but requires extensive configuration for each application endpoint.

Negative Security Model (Blocklisting)

Maintains a database of known attack signatures and blocks matching requests. Easier to deploy but can't catch zero-day attacks. Most managed rulesets use this approach.

Anomaly Scoring

Assigns points for each suspicious characteristic. When a request's total score exceeds a threshold, it's blocked. This approach (used by OWASP Core Rule Set) reduces false positives by requiring multiple suspicious signals.

Protecting Against OWASP Top 10

OWASP VulnerabilityWAF ProtectionRule Type
SQL InjectionDetect SQL syntax in parameters, headers, cookiesManaged + Custom
XSS (Cross-Site Scripting)Block script tags, event handlers, encoded payloadsManaged
Broken AuthenticationRate limit login endpoints, detect credential stuffingCustom + Rate Limiting
Server-Side Request ForgeryBlock internal IP requests, validate URLs in parametersCustom
Security MisconfigurationBlock access to admin panels, config files, .env filesCustom
File Inclusion (LFI/RFI)Detect path traversal patterns (../, etc.)Managed
XML External Entity (XXE)Inspect XML payloads for entity declarationsManaged

WAF Types

TypeExamplesBest ForPros/Cons
Cloud-based WAFCloudflare, AWS WAF, AkamaiMost websites and APIsEasy deployment, scales automatically, CDN included / Less customisable
Host-based WAFModSecurity, NAXSISelf-managed serversFull control, open source / Requires expertise, manual updates
Network-based WAFF5 BIG-IP, Fortinet FortiWebEnterprise data centresLowest latency, hardware-accelerated / Expensive, complex deployment

Cloudflare WAF Configuration

Cloudflare WAF is the most popular cloud WAF, included with Pro (£20/mo) and above plans:

Writing Custom WAF Rules

Block Access to Sensitive Files

Block requests to configuration files, environment files, and admin paths that shouldn't be publicly accessible (.env, .git, wp-admin, phpMyAdmin, etc.).

Protect Login Endpoints

Apply strict rate limiting to login, registration, and password reset endpoints. Combine with bot management to block credential stuffing attacks.

Geographic Restrictions

If your application serves specific regions, block or challenge traffic from unexpected countries, especially for admin panels and APIs.

Rate Limiting and Throttling

Rate limiting is one of the most effective WAF techniques:

Integrating WAF with DDoS & Bot Protection

WAF works best as part of a layered security stack:

  1. CDN/Anycast network: Absorbs volumetric DDoS attacks
  2. DDoS protection: Handles L3/L4 protocol attacks
  3. WAF: Filters L7 application attacks (SQL injection, XSS, etc.)
  4. Bot management: Identifies automated threats using fingerprinting and behavioural analysis
  5. Rate limiting: Constrains abuse from individual sources

WAF Solutions Compared

SolutionBest ForPricing
Cloudflare WAFMost websites, integrated CDN+DDoS+WAF+BotFrom 0/mo (Pro)
AWS WAFAWS-hosted applications$5/mo + $0.60/million requests
Akamai App & API ProtectorEnterprise, high-traffic sitesEnterprise pricing
Imperva WAFCompliance-heavy industries (PCI-DSS)From $$$
ModSecurity (open source)Self-managed servers, full controlFree (self-managed)
Sucuri WAFWordPress sites, small businessesFrom £9.99/mo

WAF Best Practices

Need Security Infrastructure Setup?

Our team configures WAF, DDoS protection, bot management, and security monitoring for websites and applications. Complete protection from application to network layer.

Get Security Consultation →

Comments

Have a question or a first-hand experience with this? Join the conversation. Your email is never shown or shared.

    Chris T.

    Great article. Any case studies showing ROI?

    Author

    Great question! This is something we see frequently with our clients. The key is consistency rather than a one-time fix.

Join the conversation

No HTML. Comments are moderated; they appear after review.

What You Get

High Trust Score

Pre-established account with positive activity history and cleared standing

Ready to Spend

Skip the warm-up phase - accounts are ready for immediate campaign launch

High Spend Ceiling

Elevated daily and monthly spend limits from day one

30-Day Replacement

Full replacement if account triggers suspension within 30 days

24h Delivery

Credentials delivered within 24 hours of payment confirmation

Dedicated Support

Direct Telegram/WhatsApp line to your account manager

WhatsApp Telegram