# Правило 1: Разрешить curl (должно быть ПЕРВЫМ)
# Если User-Agent начинается с "curl/", отключаем WAF для этого запроса
SecRule REQUEST_HEADERS:User-Agent "@beginsWith curl/" \
    "id:100000, \
    phase:1, \
    pass, \
    nolog, \
    ctl:ruleEngine=Off"

# Правило 2: Блокировать пустой User-Agent
SecRule &REQUEST_HEADERS:User-Agent "@eq 0" \
    "id:100001, \
    phase:1, \
    deny, \
    status:403, \
    log, \
    msg:'Missing User-Agent Blocked', \
    tag:'bot-protection'"

SecRule REQUEST_HEADERS:User-Agent "^$" \
    "id:100002, \
    phase:1, \
    deny, \
    status:403, \
    log, \
    msg:'Empty User-Agent Blocked', \
    tag:'bot-protection'"

# Правило 3: Блокировать известных ботов
SecRule REQUEST_HEADERS:User-Agent "@rx (?i)(python-requests|Go-http-client|Scrapy|AhrefsBot|SemrushBot|MJ12bot|wget|Java/|libwww|Lynx|HTTrack|omgili|socialmediascanner|Jooblebot|SeznamBot|Scrapy|CCBot|linkfluence|veoozbot|Leikibot|Seopult|Faraday|hybrid|Go-http-client|SMUrlExpander|SNAPSHOT|getintent|ltx71|Nuzzel|SMTBot|Laserlikebot|facebookexternalhit|mfibot|OptimizationCrawler|crazy|Dispatch|ubermetrics|HTMLParser|musobot|filterdb|InfoSeek|omgilibot|DomainSigma|SafeSearch|CommentReader|meanpathbot|statdom|proximic|spredbot|StatOnlineRuBot|openstat|DeuSu|semantic|postano|masscan|Embedly|NewShareCounts|linkdexbot|GrapeshotCrawler|Digincore|NetSeer|help.jp|PaperLiBot|getprismatic|360Spider|Ahrefs|ApacheBench|Aport|Applebot|archive|BaiduBot|Baiduspider|Birubot|BLEXBot|bsalsa|Butterfly|Buzzbot|BuzzSumo|CamontSpider|dataminr|discobot|DomainTools|DotBot|Exabot|Ezooms|FairShare|FeedFetcher|FlaxCrawler|FlightDeckReportsBot|FlipboardProxy|FyberSpider|Gigabot|HTTrack|ia_archiver|InternetSeer|Jakarta|Java|JS-Kit|km.ru|kmSearchBot|Kraken|larbin|libwww|Lightspeedsystems|Linguee|LinkBot|LinkExchanger|LinkpadBot|LivelapBot|LoadImpactPageAnalyzer|lwp-trivial|majestic|Mediatoolkitbot|MegaIndex|MetaURI|MJ12bot|MLBot|NerdByNature|NING|NjuiceBot|Nutch|OpenHoseBot|Panopta|pflab|pirst|PostRank|crawler|ptd-crawler|Purebot|PycURL|Python|QuerySeekerSpider|rogerbot|Ruby|SearchBot|SemrushBot|SISTRIX|SiteBot|Slurp|Sogou|solomono|Soup|spbot|suggybot|Superfeedr|SurveyBot|SWeb|trendictionbot|TSearcher|ttCrawler|TurnitinBot|TweetmemeBot|UnwindFetchor|urllib|uTorrent|Voyager|WBSearchBot|Wget|WordPress|woriobot|Yeti|YottosBot|Zeus|zitebot|ZmEu|Crowsnest|PaperLiBot|peerindex|Twiceler|BTWebClient|Tagoobot|igdeSpyder|Copier|netvampire|Offline|Teleport|WebCopier)" \
    "id:100003, \
    phase:1, \
    deny, \
    status:403, \
    log, \
    msg:'Bad Bot Blocked', \
    tag:'bot-protection'"