[deploy] Throttle General Site Requests (#7418)
This commit is contained in:
parent
02264a234d
commit
edcd019e9c
2 changed files with 7 additions and 0 deletions
|
|
@ -16,4 +16,10 @@ class Rack::Attack
|
|||
request.env["HTTP_API_KEY"]
|
||||
end
|
||||
end
|
||||
|
||||
throttle("site_hits", limit: 100, period: 2) do |request|
|
||||
if request.env["HTTP_FASTLY_CLIENT_IP"].present?
|
||||
request.env["HTTP_FASTLY_CLIENT_IP"].to_s
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ describe Rack::Attack, type: :request, throttle: true do
|
|||
redis_url = "redis://localhost:6379"
|
||||
cache_db = ActiveSupport::Cache::RedisStore.new(redis_url)
|
||||
allow(Rails).to receive(:cache) { cache_db }
|
||||
cache_db.data.flushdb
|
||||
end
|
||||
|
||||
describe "search_throttle" do
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue