# ==============================================================================
# Utilvo EdgeShield v1.1.0 — Apache 2.4 / LiteSpeed / cPanel Bot & ASN Firewall
# URL: https://utilvo.com/edge-shield/apache-bot-shield.conf
# Docs & Interactive Customizer: https://utilvo.com/edge-shield
# Live CIDR Feed: https://utilvo.com/api/edge-shield/threats?format=cidr
#
# Installation (Ubuntu / Debian):
# sudo curl -fsSL https://utilvo.com/edge-shield/apache-bot-shield.conf \
# -o /etc/apache2/conf-available/utilvo-edge-shield.conf
# sudo a2enmod remoteip setenvif authz_core rewrite
# sudo a2enconf utilvo-edge-shield
# sudo apache2ctl configtest && sudo systemctl reload apache2
#
# Installation (RHEL / AlmaLinux / Rocky / CentOS / cPanel):
# sudo curl -fsSL https://utilvo.com/edge-shield/apache-bot-shield.conf \
# -o /etc/httpd/conf.d/utilvo-edge-shield.conf
# sudo httpd -t && sudo systemctl reload httpd
# ==============================================================================
# 1. Restore Real Visitor IP Behind Cloudflare & Reverse Proxies (mod_remoteip)
RemoteIPHeader CF-Connecting-IP
RemoteIPInternalProxy 127.0.0.1 ::1 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16
RemoteIPInternalProxy 173.245.48.0/20 103.21.244.0/22 103.22.200.0/22 103.31.4.0/22
RemoteIPInternalProxy 141.101.64.0/18 108.162.192.0/18 190.93.240.0/20 188.114.96.0/20
RemoteIPInternalProxy 197.234.240.0/22 198.41.128.0/17 162.158.0.0/15 104.16.0.0/13
RemoteIPInternalProxy 104.24.0.0/14 172.64.0.0/13 131.0.72.0/22
# 2. SEO Safe-Harbor Whitelist & Spoofed Headless UA Classification (mod_setenvif)
# Verified Search Engine & Ad Crawlers (Safe-Harbor Whitelist)
SetEnvIfNoCase User-Agent "(Googlebot|Google-InspectionTool|Storebot-Google|AdsBot-Google|GoogleOther)" utilvo_seo_safe=1
SetEnvIfNoCase User-Agent "(bingbot|AdIdxBot|MicrosoftPreview|msnbot|Applebot|DuckDuckBot|YandexBot)" utilvo_seo_safe=1
SetEnvIfNoCase User-Agent "(facebookexternalhit|Twitterbot|LinkedInBot|Slackbot|Stripe|UptimeRobot)" utilvo_seo_safe=1
# Known AI Scrapers, Headless Chromium & Hardcoded iOS 13.2.3 DevTools Emulator
SetEnvIfNoCase User-Agent "(TokenFoundryBot|QlyzeBot|Bytespider|PetalBot|ClaudeBot|CCBot|GPTBot)" utilvo_bad_bot_ua=1
SetEnvIfNoCase User-Agent "(HeadlessChrome|PhantomJS|Writefull|Barkrowler|BLEXBot|DataForSeoBot)" utilvo_bad_bot_ua=1
SetEnvIfNoCase User-Agent "CPU iPhone OS 13_2_3 like Mac OS X" utilvo_bad_bot_ua=1
# 3. Native Apache 2.4 CIDR Radix-Tree & Environment Firewall (mod_authz_core)
# Always allow verified SEO crawlers (Safe-Harbor priority)
Require env utilvo_seo_safe
# Otherwise require ALL of the following protections to pass:
Require all granted
# Block spoofed headless / AI scraper User-Agents
Require not env utilvo_bad_bot_ua
# Block AS132203 / AS45090 — Tencent Cloud Rotating Scraper Subnets
Require not ip 43.128.0.0/10
Require not ip 101.32.0.0/15
Require not ip 119.28.0.0/16
Require not ip 124.156.0.0/16
Require not ip 129.226.0.0/16
Require not ip 150.109.0.0/16
Require not ip 162.62.0.0/16
Require not ip 170.106.0.0/16
# Block AS45102 / AS37963 — Alibaba Cloud Rotating Scraper Subnets
Require not ip 43.119.0.0/16
Require not ip 47.74.0.0/15
Require not ip 47.82.0.0/16
Require not ip 47.88.0.0/15
Require not ip 47.236.0.0/14
Require not ip 47.240.0.0/13
Require not ip 47.250.0.0/14
Require not ip 8.208.0.0/12
# Block AS136907 — Huawei Cloud Rotating Scraper Subnets
Require not ip 149.232.0.0/16
Require not ip 159.138.0.0/16
Require not ip 114.119.0.0/16
Require not ip 46.250.0.0/16