Hello,
Please do not respond to old discussions. The chances of someone noticing your message are slight.
I can't find any information about configuring fail2ban with RabbitMQ, however you should be able to configure it by doing the following:
* Set up RabbitMQ
* Make an unauthorized connection to port 5672
* See what is logged
Using RabbitMQ 3.7.15, here is what is logged when a client connects with invalid credentials:
2019-06-05 10:53:23.899 [info] <0.532.0> accepting AMQP connection <0.532.0> (127.0.0.1:54820 -> 127.0.0.1:5672)
2019-06-05 10:53:23.901 [error] <0.532.0> Error on AMQP connection <0.532.0> (127.0.0.1:54820 -> 127.0.0.1:5672, state: starting):
PLAIN login refused: user 'foo' - invalid credentials
2019-06-05 10:53:23.902 [info] <0.532.0> closing AMQP connection <0.532.0> (127.0.0.1:54820 -> 127.0.0.1:5672)
Notice that the start and end of every connection attempt is logged. You can use this, along with the timestamp values, to come up with rules to exclude repeated connection attempts within a certain time window.
Here is what is logged if you connect to port 5672 but do not complete the AMQP handshake. If a malicious user is trying to find an open port this would be logged:
2019-06-05 10:55:43.176 [info] <0.544.0> accepting AMQP connection <0.544.0> ([::1]:54841 -> [::1]:5672)
2019-06-05 10:55:43.177 [error] <0.544.0> closing AMQP connection <0.544.0> ([::1]:54841 -> [::1]:5672):
{handshake_timeout,handshake}
HAProxy is an alternative:
http://www.loadbalancer.org/blog/simple-denial-of-service-dos-attack-mitigation-using-haproxy-2/
Thanks -
Luke