Do 2 pages per second really count as "intense" activity? Even if I was hosting a website on a $5 VPS, I don't think I'd even notice anything short of 100 requests per second, in terms of resource usage.
It's common to use the host's firewall as well (nftables, firewalld, or iptables).
You can do it at the webserver too, with access.conf in nginx. Apache uses mod_authz.
I usually do it at the network though so it uses the least amount of resources (no connection ever gets to the webserver). Though if you only have access to your webserver it's faster to ban it there than to send a request to the network team (depending on your org, some orgs might have this automated).
deny 1.2.3.0/24;
And all 256 ips from 1.2.3.0 to 1.2.3.255 get banned. You can have multiple "deny" lines, or a file with "deny" and then include it.It's better to do it at the firewall.
An open web that block scraping… is likely “not an open web”
if ($http_user_agent ~ facebook) { return 444; }
if ($http_user_agent ~ Amazonbot) { return 444; }
if ($http_user_agent ~ Bytespider) { return 444; }
if ($http_user_agent ~ GPTBot) { return 444; }
if ($http_user_agent ~ ClaudeBot) { return 444; }
if ($http_user_agent ~ ImagesiftBot) { return 444; }
if ($http_user_agent ~ CCBot) { return 444; }
if ($http_user_agent ~ ChatGPT-User) { return 444; }
if ($http_user_agent ~ omgili) { return 444; }
if ($http_user_agent ~ Diffbot) { return 444; }
if ($http_user_agent ~ Claude-Web) { return 444; }
if ($http_user_agent ~ PerplexityBot) { return 444; }
(edit: see replies to do it in a cleaner way)[1] https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#ngin...
[2] https://blog.cloudflare.com/declaring-your-aindependence-blo...
include /etc/nginx/useragent.rules;
In /etc/nginx/useragent.rules map $http_user_agent $badagent {
default 0;
~facebook 1;
[...]
~PerplexityBot 1;
}
In your site.conf, server block, add if ($badagent) {
return 444;
}Only if they ignore robots.txt the access rules will stop them.
See also https://stackoverflow.com/questions/5238377/nginx-location-p...
Amazonbot, anthropic-ai, AwarioRssBot, AwarioSmartBot, Bytespider, CCBot, ChatGPT-User, ClaudeBot, Claude-Web, cohere-ai, DataForSeoBot, Diffbot, Webzio-Extended, FacebookBot, FriendlyCrawler, Google-Extended, GPTBot, 0AI-SearchBot, ImagesiftBot, Meta-ExternalAgent, Meta-ExternalFetcher, omgili, omgilibot, PerplexityBot, Quora-Bot, TurnitinBot
For all of these bots,
User-agent: <Bot Name> Disallow: /
For more information, check https://darkvisitors.com/agents
If this takes off, I've made my own variant of llms.txt here: https://boehs.org/llms.txt . I hereby release this file to the public domain, if you wish to adapt and reuse it on your own site.
Hall of shame: https://www.404media.co/websites-are-blocking-the-wrong-ai-s...