I haven't found this any where in heroku's documentation or on google. Typically this is done in the host file. Does anyone have any idea how to block an ip on heroku?
Since this was first answered, Heroku has added a Web Application Firewall in their AddOn Marketplace: https://elements.heroku.com/addons/expeditedwaf
It can block inbound requests by IP, UserAgent, Referrer, Country, etc.
Heroku doesn't have a firewall that you can use to block IPs, so you would have to either block it at the application level, or you would have to put a proxy of some sort in front of your application that you can use to block the IP. One common one people use is CloudFlare, which has support for blocking individual IPs, rate limiting IPs, etc.
If you want to stick with blocking at the application level, and are using Ruby on Rails, this question and answer which might give you what you're looking for: How can you block or filter IP addresses on Heroku?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With