How can you block or filter IP addresses on Heroku?

前端 未结 2 950
抹茶落季
抹茶落季 2020-12-29 04:52

Is there a way to implement IP filtering or IP access rules much like I would with nginx/apache to restrict or block certain IPs on Heroku?

Note: I

2条回答
  •  既然无缘
    2020-12-29 05:33

    You should check out rack-attack. Looks like it does the same as rack-block, but is much more widely used and updated frequently. To block a specific IP you can do this:

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

提交回复
热议问题