# Block AI bots with relayd on OpenBSD 2024-11-27T09:08:57Z According to their advertised User-Agent, you can block AI scrapers with relayd. To do so, I suggest to use tags Every unwanted user-agent will be tagged, then every request with the above tag is discarded. To simplify future work, I suggest to include a file in /etc/relayd.conf: ``` http protocol "http" { return error tls keypair ... include "/etc/relayd.d/ai.conf" # <--- HERE pass } ``` Now, in /etc/relayd.d/ai.conf, let's add a few user-agent ``` # AI match request header "User-Agent" value "AI2Bot" tag "AI" match request header "User-Agent" value "Ai2Bot-Dolma" tag "AI" match request header "User-Agent" value "Amazonbot" tag "AI" match request header "User-Agent" value "anthropic-ai" tag "AI" match request header "User-Agent" value "Applebot" tag "AI" match request header "User-Agent" value "Applebot-Extended" tag "AI" match request header "User-Agent" value "Bytespider" tag "AI" match request header "User-Agent" value "CCBot" tag "AI" match request header "User-Agent" value "ChatGPT-User" tag "AI" match request header "User-Agent" value "Claude-Web" tag "AI" match request header "User-Agent" value "ClaudeBot" tag "AI" match request header "User-Agent" value "cohere-ai" tag "AI" match request header "User-Agent" value "Diffbot" tag "AI" match request header "User-Agent" value "DuckAssistBot" tag "AI" match request header "User-Agent" value "FacebookBot" tag "AI" match request header "User-Agent" value "FriendlyCrawler" tag "AI" match request header "User-Agent" value "Google-Extended" tag "AI" match request header "User-Agent" value "GoogleOther" tag "AI" match request header "User-Agent" value "GoogleOther-Image" tag "AI" match request header "User-Agent" value "GoogleOther-Video" tag "AI" match request header "User-Agent" value "GPTBot" tag "AI" match request header "User-Agent" value "iaskspider/2.0" tag "AI" match request header "User-Agent" value "ICC-Crawler" tag "AI" match request header "User-Agent" value "ImagesiftBot" tag "AI" match request header "User-Agent" value "img2dataset" tag "AI" match request header "User-Agent" value "ISSCyberRiskCrawler" tag "AI" match request header "User-Agent" value "Kangaroo" tag "AI" match request header "User-Agent" value "Meta-ExternalAgent" tag "AI" match request header "User-Agent" value "Meta-ExternalFetcher" tag "AI" match request header "User-Agent" value "OAI-SearchBot" tag "AI" match request header "User-Agent" value "omgili" tag "AI" match request header "User-Agent" value "omgilibot" tag "AI" match request header "User-Agent" value "PanguBot" tag "AI" match request header "User-Agent" value "PerplexityBot" tag "AI" match request header "User-Agent" value "PetalBot" tag "AI" match request header "User-Agent" value "Scrapy" tag "AI" match request header "User-Agent" value "Sidetrade" tag "AI" match request header "User-Agent" value "Timpibot" tag "AI" match request header "User-Agent" value "VelenPublicWebCrawler" tag "AI" match request header "User-Agent" value "Webzio-Extended" tag "AI" match request header "User-Agent" value "YouBot" tag "AI" block request quick tagged "AI" label "I don't feed IA" ``` As you can see, in the end, I add a little message :) The user-agent list has been found here: => https://raw.githubusercontent.com/ai-robots-txt/ai.robots.txt/refs/heads/main/robots.txt) After reloading relayd, check it works as expected with curl: ``` > curl -H "User-Agent:GPTBot" https://si3t.ch [... snip ...]