Rack::Attack.blocklist('bot_php') do |req|
Rack::Attack::Allow2Ban.filter(req.ip, maxretry: 5, findtime: 1.minute, bantime: 1.hour) do
next unless req.path.end_with?('.php') || req.path.include?('wp-admin')
req.ip
end
New blocklist definition:
Rack::Attack.blocklist('bot_php') do |req|
Rack::Attack.def_allow2ban('bot_php', limit: 5, period: 1.minute, bantime: 1.hour)
Rack::Attack.allow2ban('bot_php', req.ip) do
next unless req.path.end_with?('.php') || req.path.include?('wp-admin')
req.ip
end
end
Result when visiting the admin dashboard:
Showing /home/nowaker/projekty/modern/rack_attack_admin/app/views/rack_attack_admin/rack_attack/index.html.haml where line #80 raised:
undefined method `limit' for #<Rack::Attack::Blocklist:0x000055c369b07340>
Original blocklist definition:
New blocklist definition:
Result when visiting the admin dashboard:
Broken HAML line:
It suggests
Rack::Attack::Fail2Ban
is notInstantiableFail2Ban
. Why? No idea.