소스 검색

allow localhost to bypass the ratelimit (#2554)

master
Tristan Mahé 7 년 전
committed by Eugen Rochko
부모
커밋
964035b118
1개의 변경된 파일7개의 추가작업 그리고 0개의 파일을 삭제
  1. +7
    -0
      config/initializers/rack_attack.rb

+ 7
- 0
config/initializers/rack_attack.rb 파일 보기

@@ -1,6 +1,13 @@
# frozen_string_literal: true

class Rack::Attack
# Always allow requests from localhost
# (blocklist & throttles are skipped)
Rack::Attack.safelist('allow from localhost') do |req|
# Requests are allowed if the return value is truthy
'127.0.0.1' == req.ip || '::1' == req.ip
end

# Rate limits for the API
throttle('api', limit: 300, period: 5.minutes) do |req|
req.ip if req.path =~ /\A\/api\/v/


불러오는 중...
취소
저장