Skip to content

Commit 60b680c

Browse files
committed
Add throttling rule
1 parent e6ac57e commit 60b680c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

config/initializers/rack_attack.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
class Rack::Attack
22
Rack::Attack.enabled = Rails.env.production?
33

4+
Rack::Attack.throttle("requests by ip", limit: 5, period: 2) do |request|
5+
request.ip
6+
end
7+
48
Rack::Attack.blocklist("php-bots") do |req|
59
req.ip if /\S+\.php/.match?(req.path)
610
end

0 commit comments

Comments
 (0)