security - How do you block specific IP adress in Ruby on Rails -
I am in charge of some live websites made on Rail's Ruby. I have some IP ads that attack these sites and I would like to block my IP address. I know that they can get around this wall with a proxy, but I want to make it hard for myself and want to know where I should set in my Ruby on Rail app. Thanks to all of you!
class ApplicationController & lt; ActionController :: Base before_filter: block_ip_addresses protected def block_ip_addresses head: unauthorized if current_ip_address == "XX.XX.XX.XX" end DEF current_ip_address request.env ['HTTP_X_REAL_IP'] || Thanks for request.env ['REMOTE_ADDR'] End End :
Comments
Post a Comment