Skip to content

Commit

Permalink
Throttle initial search page requests too.
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Jul 8, 2024
1 parent dbe2fd2 commit 79e9887
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion config/initializers/rack_attack.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# Throttle catalog search and result requests by IP (10rpm over 1 minute)
Rack::Attack.throttle('req/ip/1m', limit: 15, period: 1.minutes) do |req|
req.ip if req.path == '/all'
end

Rack::Attack.throttle('req/ip/5m', limit: 50, period: 5.minutes) do |req|
req.ip if req.path == '/all'
end

# Throttle catalog search and result requests by IP (10rpm over 1 minute)
Rack::Attack.throttle('req/ip/catalog/1m', limit: 10, period: 1.minutes) do |req|
req.ip if req.path.start_with?('/all/xhr_search/catalog')
end
Expand Down

0 comments on commit 79e9887

Please sign in to comment.