Skip to content

Instantly share code, notes, and snippets.

@dcuadraq
Last active December 21, 2016 17:19
Show Gist options
  • Save dcuadraq/af262a98b2455840ec60c03b25c3b5e0 to your computer and use it in GitHub Desktop.
Save dcuadraq/af262a98b2455840ec60c03b25c3b5e0 to your computer and use it in GitHub Desktop.
rack-attack gem

Examples

Block requests with matching header

class Rack::Attack
  throttle('req/ip', limit: 0, period: 1.second) do |req|
    req.ip if req.env['HTTP_X_SCANNER'] == 'Netsparker' ||
              req.params['email'] == 'netsparker@example.com'
  end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment