# /**
#  * @version    2.13
#  * @package    Engintron for cPanel/WHM
#  * @author     Fotis Evangelou (https://kodeka.io)
#  * @url        https://engintron.com
#  * @copyright  Copyright (c) 2014 - 2026 Kodeka OÜ. All rights reserved.
#  * @license    GNU/GPL license: https://www.gnu.org/copyleft/gpl.html
#  */

# ~ Common simple protection against IPs and bots ~

# Block IPs
# ------------------------------------------------------------ #
# ~ Determine IPs with most connections...
# Check single access log file:
# $ cd /home/USERNAME/domains/DOMAIN/logs/
# $ cat access.log | cut -f1 -d ' ' | sort | uniq -c | sort -g
#
# Check all access log files:
# $ cat /home/*/domains/*/logs/access.log | cut -f1 -d ' ' | sort | uniq -c | sort -g
#
# ~ Tool to use for IP range to CIDR: https://www.ipaddressguide.com/cidr
#


# Add IPs to block following this format: deny 1.2.3.4;
# ------------------------------------------------------------ #


# Common bots and crawlers to exclude
# ------------------------------------------------------------ #
if ($http_user_agent ~* "awariobot|awariorssbot|awariosmartbot|backlinksextendedbot|barkrowler|blexbot|brandwatch\.net|bytedance\.com|bytespider|coccocbot|criteobot|dataforseobot|deadlinkchecker|domainstatsbot|dotbot|grapeshotcrawler|imagesiftbot|lamarkbot|mixrankbot|mj12bot|mojeekbot|paqlebot|peer39_crawler|petalbot|proximic|semantic-visions\.com|serpstatbot|siteauditbot|seobilitybot|tenmilliondomainsbot|timpibot|trendictionbot|virustotalbot|yodaobot|zoominfobot") {
    return 444;
}
if ($http_user_agent ~* "amazonbot|meta-webindexer") {
    return 444;
}

# AI Bots & Crawlers
if ($http_user_agent ~* "ai2bot|aliyunsec|anthropic|chatgpt|claude|cohere|gptbot|mistral|openai|perplexity|searchbot") {
    return 444;
}

# Feed Parsers
if ($http_user_agent ~* "SimplePie|sindresorhus/got|UniversalFeedParser") {
    return 444;
}

# Scanners
if ($http_user_agent ~* "botpoke|censysinspect|expanse|keydrop|l9explore|l9tcpid|shodan") {
    return 444;
}

# SEO Bots
if ($http_user_agent ~* "ahrefs\.com|ahrefsbot|ahrefssiteaudit|moz\.com|semrush") {
    return 444;
}

# No User-Agent
# Off by default as this may break cURL/wget cron jobs that don't set a user-agent - use with caution
#if ($http_user_agent = "") {
#    return 444;
#}
