commit: 3b56350121998abb249f14a45c656c2655d6344e
parent: db6df6ddb3448a28c56dff08e6442e4109e6fab2
Author: Eugen Rochko <eugen@zeonfederated.com>
Date: Sat, 24 Sep 2016 13:53:54 +0200
Fix #6 - Rate limit GET reqs to 300/5min, POST to 100/5min
Diffstat:
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/config/initializers/rack-attack.rb b/config/initializers/rack-attack.rb
@@ -1,5 +1,9 @@
class Rack::Attack
- throttle('req/ip', limit: 300, period: 5.minutes) do |req|
- req.ip
+ throttle('get-req/ip', limit: 300, period: 5.minutes) do |req|
+ req.ip if req.get?
+ end
+
+ throttle('post-req/ip', limit: 100, period: 5.minutes) do |req|
+ req.ip if req.post?
end
end