Files
chef/site-cookbooks/kosmos_gitea/files/rate_limits.conf
T
greg 051c497054 Rate limit requests from bots on Gitea
For now this is 240 r/m (4r/s), for Claude, Sogou and Meta user agents.
The values are pretty conservative, I initially had tighter limits.
Let's see how it goes, this is running on Fornax and Draco and right now
we're not hitting the limits.
2026-08-01 16:33:35 +02:00

26 lines
775 B
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Increase if you have very long User-Agent strings
map_hash_bucket_size 256;
# Bot user agents
map $http_user_agent $bot_name {
default "";
~*ClaudeBot "claude";
~*Sogou "sogou";
~*meta-externalagent "meta-externalagent";
# add more as needed
}
# Decide the rate-limit key (per-IP for each bot in this example)
map $bot_name $bot_limit_key {
default "";
"claude" $binary_remote_addr;
"sogou" $binary_remote_addr;
"meta-externalagent" $binary_remote_addr;
}
# Shared memory zone only non-empty keys are counted
limit_req_zone $bot_limit_key zone=bots:20m rate=240r/m; # 4r/s per IP+bot
# Status code returned when the limit is exceeded
limit_req_status 429;