From 26977d06a881cffa802c3f820aff7c116593e052 Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Thu, 29 Sep 2016 13:15:14 +0800 Subject: [PATCH] disable 5 minute request limit on rack attack --- config/initializers/rack-attack.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/config/initializers/rack-attack.rb b/config/initializers/rack-attack.rb index 9dfe3746..1cb90f0f 100644 --- a/config/initializers/rack-attack.rb +++ b/config/initializers/rack-attack.rb @@ -4,9 +4,9 @@ class Rack::Attack # Throttle all requests by IP (60rpm) # # Key: "rack::attack:#{Time.now.to_i/:period}:req/ip:#{req.ip}" - throttle('req/ip', :limit => 300, :period => 5.minutes) do |req| - req.ip # unless req.path.start_with?('/assets') - end + # throttle('req/ip', :limit => 300, :period => 5.minutes) do |req| + # req.ip # unless req.path.start_with?('/assets') + # end # Throttle POST requests to /login by IP address # @@ -32,7 +32,10 @@ class Rack::Attack end end - throttle('load_url_title/req/ip', :limit => 5, :period => 1.second) do |req| + throttle('load_url_title/req/5mins/ip', :limit => 300, :period => 5.minutes) do |req| + req.ip if req.path == 'hacks/load_url_title' + end + throttle('load_url_title/req/1s/ip', :limit => 5, :period => 1.second) do |req| # If the return value is truthy, the cache key for the return value # is incremented and compared with the limit. In this case: # "rack::attack:#{Time.now.to_i/1.second}:load_url_title/req/ip:#{req.ip}"