--
Automated scrapers, AI training crawlers, and credential stuffing bots account for over 40% of all internet traffic.
Allowing bots to scrape your web application without restrictions inflates hosting bills, degrades performance for real users, and drains database connection pools.
In this tutorial, we are going to use Aegis—an open-source, self-hosted Web Application Firewall (WAF) and reverse proxy—to configure automated bot defense, manage AI scrapers, and deploy client-side cryptographic browser challenges.
Step 1: Access Bot Defense Settings
- Open your Aegis Admin Console at
http://server-ip:8081. - In the left navigation menu, navigate to Traffic Control > Bot Defense.
- Toggle on Enable Bot Protection.
Aegis evaluates incoming client fingerprints, request headers, and traffic behavioral patterns in real time.
Step 2: Configure AI Crawlers and Scraper Policies
Manage how automated crawlers access your site:
- Search Engine Crawlers: Toggle on Allow Verified Search Engines (Googlebot, Bingbot, DuckDuckGo). Aegis verifies reverse-DNS signatures to ensure fake bots cannot spoof search engine user-agents.
-
AI Scrapers & Training Bots: Select your policy for known AI crawlers (GPTBot, CCBot, Anthropic, Bytespider):
-
Block: Immediately drop requests with
HTTP 403 Forbidden. - Challenge: Require the bot to pass a client-side challenge.
-
Block: Immediately drop requests with
- Click Apply Policy.
Step 3: Deploy Client-Side Browser Challenges (Smart Challenge)
For requests that exhibit suspicious behavior or exceed baseline request velocities:
- Under Mitigation Strategy, select Browser Challenge (Smart Challenge).
- When a suspected bot requests a protected page, Aegis returns a lightweight HTML payload that executes a fast cryptographic challenge in the background.
- Genuine human visitors running modern web browsers solve the challenge automatically in milliseconds without seeing a CAPTCHA.
- Headless scripts, scraping tools, and automated botnets fail the execution and are dropped at the edge.
Step 4: Verify Bot Mitigation
Test the endpoint with an automated CLI client:
curl -i -A "GPTBot/1.0" http://localhost:8080/
Response:
HTTP/1.1 403 Forbidden
Content-Type: text/html; charset=utf-8
X-Aegis-Action: bot-blocked
Access denied: Automated AI scraper blocked by security policy.
The request is rejected at the ingress proxy and never reaches your origin web server.
Resources
The Community Edition is free to self-host:
- Aegis GitHub Repository: https://github.com/divinelabio/aegis
- Documentation: https://divinelab.io/products/aegis/docs/traffic-control/overview

Top comments (2)
Good walkthrough of the Aegis setup. One addition for the IP reputation denylist part: many scrapers now rotate through residential proxies, so a static list of bad IPs misses a lot of them. Classifying each IP by type (hosting, residential proxy, VPN, Tor, known bot) lets you apply different rules per type instead of one blanket list. The ipgeolocation.io IP Security API returns those flags plus a threat score in one call (ipgeolocation.io/ip-security-api.html).
40% là con số đáng lo, nhưng thực tế nhiều trang web nội bộ của mình thấy con số này còn cao hơn — đặc biệt là các endpoint API public và trang login. Một vài điều mình áp dụng và thấy hiệu quả:
Rate limiting theo fingerprint chứ không chỉ IP — bot farm hiện nay xoay proxy liên tục, nhưng fingerprint trình duyệt (canvas, fonts, timing) khó giả mạo hơn. Thư viện open-source như FingerprintJS (phiên bản community) giúp khá nhiều.
Challenge-response cho traffic đáng ngờ — thay vì block ngay, trả về JavaScript challenge hoặc proof-of-work nhẹ. Bot headless thường fail ở đây vì không thực thi JS đầy đủ, còn user thật hầu như không cảm thấy.
Honeypot field ẩn — thêm input
display:nonevào form login/register. Bot tự động fill hết field, user thật không thấy. Cực đơn giản nhưng lọc được 80% credential stuffing cơ bản.Behavioral analysis — track mouse movement, scroll pattern, time-between-requests. Bot script thường có pattern quá đều hoặc quá nhanh. Có thể dùng Cloudflare Turnstile hoặc tự xây rule đơn giản.
Block known ASN/datacenter ranges — AWS, DigitalOcean, Hetzner... ít user thật duyệt web từ IP này. Maintain list tự cập nhật hàng tuần.
Điểm yếu chung: false positive. Luôn cần logging chi tiết và quy trình appeal cho user bị chặn nhầm. Mình hay để "soft block" (challenge) trước 2-3 tuần, mới hard block khi dữ liệu đủ thuyết phục.
Bạn nào đang dùng WAF nào (ModSecurity (site: labagent .tech)