Banning Smart Bots with NGINX ModSecurity
A technical guide to the AI Exclusion Protocol. Implementing custom ModSecurity rules, ai.txt, and security.txt to defend against aggressive marketing bots.
Agenda
-
Who is on the Blocklist?
-
The SEO Giants (Ahrefs, Semrush, Moz)
- The AI Scrapers (GPTBot, ClaudeBot, Bytespider)
-
Taking it a Step Further: The Layer 3 Ban
-
Automating the ban from NGINX logs to OPNsense Firewall
- Robots.txt Configuration
-
Offensive Defense: Poisoning the Well
-
The "Gibberish" Redirect strategy
- The Inspiration: "Nightshade" for Text
-
The New Standard: ai.txt & security.txt
-
The AI Exclusion Protocol
- RFC 9116 Compliance
-
The "Market Substitute" Trap in Fair Use
-
Is AI violating US Copyright Law?
In a previous post, I detailed the security architecture of this blog, including the use of the NGINX ModSecurity Web Application Firewall (WAF). Today, I'm sharing a specific use case for that WAF: blocking aggressive "smart bots" that provide no value to a personal technical blog.
While I welcome legitimate search engine crawlers like Googlebot, the web is full of bots that are essentially noise. These include SEO marketing crawlers, AI data scrapers, and other marketing analytics tools. They consume server resources, skew analytics, and offer zero benefit to me or my readers.
To mitigate this, I implemented a custom ModSecurity rule to block a specific list of these bot user agents at the ingress layer.
Here is an example from my NGINX error log showing the rule in action. This log entry shows an attempt by AhrefsBot to access the homepage being immediately blocked with a 403 Forbidden response.
I might add that AwarioSmartBot is the number one offender on this list. Their IPs have been banned. Their website states to add them to my robots.txt and I have done that but even if a SmartBot does not respect my robots.txt and is at least friendly enough to state who they are they'll be blocked.
SecRule REQUEST_HEADERS:User-Agent "@pm \
AwarioSmartBot \
AwarioRssBot \
AhrefsBot \
DotBot \
SemrushBot \
SemrushBot-SA \
MJ12bot \
PetalBot \
AspiegelBot \
SerpstatBot \
DataForSeoBot \
Screaming Frog SEO Spider \
ZoominfoBot \
SeekportBot \
Barkrowler \
AlphaBot \
Rogerbot \
Gigabot \
LieBaoFast \
TurnitinBot \
Meltwater \
Bytespider \
CCBot \
Diffbot \
ImagesiftBot \
ClaudeBot \
ChatGPT-User \
GPTBot \
Anthropic-AI
YaK \
Linkfluence" \
"id:10008,phase:1,deny,status:403,msg:'Blocked Marketing/AI Bot: %{MATCHED_VAR}'"
Who is on this list?
- The SEO Giants:
AhrefsBot,SemrushBot,DotBot(Moz),MJ12bot(Majestic). They are mapping the web to sell backlink data. - The AI Scrapers:
Bytespider(ByteDance/TikTok),CCBot(Common Crawl - used for GPT training),GPTBot(OpenAI),ClaudeBot(Anthropic). - The Aggressive unknowns:
PetalBot&AspiegelBot(Huawei crawlers, known for high volume),LieBaoFast. - The Marketing Analytics:
Awario,Zoominfo,Meltwater.
ModSecurity: Access denied with code 403 (phase 1). Matched "Operator `Pm' with parameter `\\x0a AwarioSmartBot AwarioRssBot AhrefsBot DotBot SemrushBot SemrushBot-SA MJ12bot \\x0a PetalBot AspiegelBot SerpstatBot DataForSeoBot Screaming Frog SEO Spider \\x0a ZoominfoBot SeekportBot Barkrowler Al (145 characters omitted)' against variable `REQUEST_HEADERS:user-agent' (Value: `AhrefsBot' ) [file "/etc/nginx/owasp-modsecurity-crs/plugins/ghost-rules.conf"] [line "45"] [id "10008"] [rev ""] [msg "Blocked Marketing/AI Bot: AhrefsBot"] [data ""] [severity "0"] [ver ""] [maturity "0"] [accuracy "0"] [hostname "www.fracturedarchitecture.com"] [uri "/"] [unique_id "177072128220.423320"] [ref "o0,9v76,9"], client: 10.0.0.1, server: www.fracturedarchitecture.com, request: "HEAD / HTTP/2.0", host: "www.fracturedarchitecture.com"
{
"transaction": {
"client_ip": "x.x.x.x",
"time_stamp": "Tue Feb 10 11:23:50 2026",
"server_id": "362463011dcabb932b94eadad106437b4d90e1c3",
"client_port": 44424,
"host_ip": "x.x.x.x",
"host_port": 80,
"unique_id": "177072263075.474794",
"request": {
"method": "GET",
"http_version": 1.1,
"uri": "/robots.txt",
"body": "",
"headers": {
"User-Agent": "AwarioSmartBot/1.0 (+https://awario.com/bots.html; bots@awario.com)",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Host": "www.fracturedarchitecture.com",
"Connection": "Keep-Alive",
"Accept-Encoding": "gzip,deflate"
}
},
"response": {
"http_code": 403,
"headers": {}
},
"producer": {
"modsecurity": "ModSecurity v3.0.14 (Linux)",
"connector": "ModSecurity-nginx v1.0.4",
"secrules_engine": "Enabled",
"components": [
"OWASP_CRS/4.22.0\""
]
},
"messages": [
{
"message": "Blocked Marketing/AI Bot: AwarioSmartBot/1.0 (+https://awario.com/bots.html; bots@awario.com)",
"details": {
"match": "Matched \"Operator `Pm' with parameter `\\\n AwarioSmartBot AwarioRssBot AhrefsBot DotBot SemrushBot SemrushBot-SA MJ12bot \\\n PetalBot AspiegelBot SerpstatBot DataForSeoBot Screaming Frog SEO Spider \\\n ZoominfoBot SeekportBot Barkrowler Al (145 characters omitted)' against variable `REQUEST_HEADERS:User-Agent' (Value: `AwarioSmartBot/1.0 (+https://awario.com/bots.html; bots@awario.com)' )",
"reference": "o0,14v37,67",
"ruleId":"10008",
"file": "/etc/nginx/owasp-modsecurity-crs/plugins/ghost-rules.conf",
"lineNumber": "45",
"data": "",
"severity": "0",
"ver": "",
"rev": "",
"tags": [],
"maturity": "0",
"accuracy": "0"
}
}
]
}
}
Robots.txt
You can check out my Robots.txt file which contains a list of bots I have banned through my robots.txt. Crawlers be aware if you cannot access my robots.txt its because I don't want you to even see that I am blocking you or who I am blocking. I'm quite sure this list will keep growing and growing. I might do an exclusive allow only robots.txt file eventually when I know what is needed.
https://www.fracturedarchitecture.com/robots.txt
Taking it a Step Further: The Layer 3 Ban
While blocking these bots at the Ingress level saves my application resources, the connection still consumes bandwidth and hits my Nginx controller. For repeat offenders or particularly aggressive scrapers, I prefer to ban their IP addresses entirely at the network perimeter.
Since I use OPNsense as my edge firewall, I can create a "Blocklist" Alias that drops packets before they even enter my Kubernetes cluster.
The Workflow:
- Identify: My Nginx ModSecurity logs identify the bot (as seen above).
- Extract: I can parse these logs to extract the source IP (
client_ip). - Ban: I add these IPs to an OPNsense Alias (e.g.,
Blocked_Marketing_Bots). - Enforce: A floating firewall rule drops all traffic from this Alias on the WAN interface.
Currently, I handle this manually for persistent offenders, but it can be automated using a log parser (like Fail2Ban or a custom Python script) that watches the Nginx logs and pushes updates to the OPNsense API. This turns my WAF into a dynamic threat intelligence feed for my firewall, moving the defense line as far forward as possible.
Offensive Defense: Poisoning the Well
Blocking a bot with a 403 Forbidden is efficient, but it's also boring. It tells the bot "You are not welcome," and the bot simply moves on to the next target.
A more interesting approach and one I am currently experimenting with is Data Poisoning.
Since these bots are scraping my content to train Large Language Models (LLMs) or build SEO keyword databases without my permission, why not feed them hallucinations?
The Concept: The "Gibberish" Redirect
Instead of a hard block, I can configure NGINX to redirect identified bots to a dedicated backend service or a static "honeypot" page.
- Identify: ModSecurity detects the
User-Agent(e.g.,GPTBot). - Redirect: Instead of
deny, NGINX performs an internal rewrite to a/poisonendpoint. - Pollute: This endpoint serves grammatically correct but factually nonsensical technical prose generated via a Markov chain or a simple randomization script.
The Inspiration: "Nightshade" for Text
In the visual art world, tools like Nightshade and** Glaze** have become famous for "poisoning" images altering pixels in invisible ways that cause AI models to mistake a dog for a cat.
I wanted to apply this same hostile defense to my text.
While there isn't a drop-in "Nightshade for Blogs" yet, the principle is simple: Data Poisoning. If an AI scraper ignores my robots.txt and 403 errors, I shouldn't just block it - I should feed it garbage.
The New Standard: ai.txt & security.txt
Beyond the brute force of a WAF, I am also implementing the emerging "polite" standards. Defense in depth means using every layer available, even the voluntary ones.
1. ai.txt (The AI Exclusion Protocol)
Just as robots.txt tells search engines what to index, ai.txt is a proposed standard specifically for AI/ML scrapers. It lives at the root of your domain (/ai.txt) and explicitly declares permissions for text and data mining.
While not all scrapers respect it yet, it is becoming the de-facto standard for ethical AI data gathering.
My ai.txt Implementation:
Plaintext
# /ai.txt
User-agent: *
Disallow: /
# Exceptions for Search Engines that respect privacy
User-agent: Google-Extended
Disallow: /
User-agent: GPTBot
Disallow: /
User-agent: CCBot
Disallow: /
# Allow basic search indexing but deny training
mining: denied
2. security.txt (RFC 9116)
I also host a security.txt file at /.well-known/security.txt. This is the IETF standard for security researchers to find your contact info if they discover a vulnerability.
If a white-hat hacker finds a bypass in my ModSecurity rules, I want them to email me, not post it on Twitter.
My security.txt:
Plaintext
Contact: mailto:security@fracturedarchitecture.com
Expires: 2026-12-31T23:59:00.000Z
Preferred-Languages: en
Canonical: https://www.fracturedarchitecture.com/.well-known/security.txt
By serving these files, I am establishing a clear, machine-readable policy: "I am a security-conscious engineer. Respect the boundaries, or deal with the WAF."
I might go ahead and write a fun Nightshade for text framework just for the fun of it. Maybe they'll stop scanning me altogether. 😄
The "Market Substitute" Trap in Fair Use
In the world of copyright, 17 U.S.C. § 107 is the governing framework for Fair Use, but there is one specific pivot point that often catches creators off guard: the** Fourth Factor**.
While many focus on whether their work is "transformative," the law includes a critical economic safeguard regarding the effect of the use upon the potential market for or value of the copyrighted work.The Replacement Clause. The core of this violation lies in whether the new content serves as a market replacement (or "market substitute"). If a person can consume your work as a way to avoid purchasing or licensing the original, you are likely "superseding the objects" of the original creator.
Legal precedent, most notably in Campbell v. Acuff-Rose Music, Inc., clarifies that Fair Use is not intended to allow a second comer to simply provide a "replacement" in the market. The law protects not just the current market, but also potential derivative markets meaning if the original creator could have licensed that specific type of use, your unauthorized version might be seen as stealing that opportunity.
Key Takeaways for Creators
- Substitution vs. Transformation: If your work adds nothing but a slightly different wrapper to the same core value, it’s a substitute.
- Economic Harm: The courts don't just look at whether you made money; they look at whether you deprived the owner of the potential to make money.
- The Scalability Test: Courts often ask: "If everyone did what you are doing, would it destroy the market for the original?" If the answer is yes, Fair Use typically fails.
In summary AI is in clear violation of US Copyright law. I am not a lawyer but this should be as clear as day for anyone. When AI is blocked from freely violating copyright its intelligence will reduce by 70%. If it licenses content its price will rise by 1000%.
Field Log Discussion
Public @handle only · Private email hidden · Fenced code blocks supported
Join the architecture review under a self-chosen @handle. Your email address is never displayed publicly.
Loading discussion notes...