I have rails3 + nginx stack.
Several days ago it was ddos attack with lots of GET requests similar to:
GET /?aaa2=bbbbbbb&ccc=1234212
GET /?aaa1=bbbbbbb&ccc=4324233
First of all I added to application controller rule:
before_filter :ddos_check
def ddos_check
params.each do |param|
if (!param[1].nil? && (param[1].is_a?String) && !param[1].scan(/bbb/sim).blank?)
redirect_to 'http://google.com/'
return
end
end
end
It protects controllers from heavy DB calls.
Is it any gems or nginx modules that can filter ddos messages with specific rules?