Overview
The Block User-Agent feature restricts access based on the HTTP User-Agent
header. When a request contains a blocked User-Agent string, the service will return an HTTP 403 Forbidden response.
This is useful for preventing spam bots, crawlers, or specific clients from accessing your application.
Configuration Options
Regex
Defines the list of comma separated user agent patterns that should be blocked.
Supports regular expressions to match multiple User-Agents.
Can be combined with regexAllow to make exceptions.
Example Scenario
Consider the following configuration:
Regex: BadBot,ApacheBench
RegexAllow: Googlebot
Request Flow:
Request # |
User-Agent |
Allowed? |
Reason |
---|---|---|---|
1 |
BadBot/1.0 |
❌ No |
Blocked by regex |
2 |
Mozilla/5.0 |
✅ Yes |
Not listed in blocked User-Agents |
3 |
ApacheBench/2.3 |
❌ No |
Blocked by regex |
4 |
Googlebot/1.1 |
✅ Yes |
Explicitly allowed by |
Use Cases
Prevent Spam Bots: Block known scrapers, spammers, and attack bots.
Restrict Load Testing Tools: Prevent unauthorized benchmarking tools like ApacheBench.
Optimize Crawler Traffic: Allow good bots (
Googlebot
,Bingbot
) while blocking unknown ones.
By using Block User-Agent, you can control bot access, reduce server load, and filter out unwanted traffic efficiently.