From 98ca9c2fc0e698ab84443b5ae45ec2fe8c642a2a Mon Sep 17 00:00:00 2001 From: zaziemo Date: Mon, 4 Nov 2024 21:46:06 +0100 Subject: [PATCH] Try to throttle OAI Searchbot more than others [#1421] --- config/initializers/rack_attack.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/initializers/rack_attack.rb b/config/initializers/rack_attack.rb index 306038958..b9e35262b 100644 --- a/config/initializers/rack_attack.rb +++ b/config/initializers/rack_attack.rb @@ -24,6 +24,10 @@ class Rack::Attack # Throttle all requests by IP (60rpm) # # Key: "rack::attack:#{Time.now.to_i/:period}:req/ip:#{req.ip}" + throttle('req/user_agent', limit: 10, period: 5.minutes) do |req| + req.user_agent == 'OAI-SearchBot' + end + throttle('req/ip', limit: 100, period: 5.minutes) do |req| req.ip end