Block IP's In a rails app on heroku

heroku, ip, ruby-on-rails

Solution

Perhaps rack-attack will do what you want?

# Block requests from 1.2.3.4
Rack::Attack.blacklist('block 1.2.3.4') do |req|
  # Request are blocked if the return value is truthy
  '1.2.3.4' == req.ip
end

Problem

I have a rails app on heroku, and there are about 10 requests per second, which is strange because no one is using the app right now. All of the requests are for URI's that are clearly attempting to exploit security vulnerabilities, for example. ``` http://myapp.com/etc/passwd ``` and things like that. How can I block this person from accessing my app? Is there a quick fix for this?

Original source