How to detect and ban IP address making too much requests with Spring Boot?

1.8k Views Asked by At

Does anyone know how to detect and ban the IP address or addresses automatically from which a lot of requests come in a very short period of time?

Example: someone has made a script to execute different special characters on an index page to try to slow or shut down the website:

https://website.com?name=23343jvugij
https://website.com?name=%ç*3233
https://website.com?name=SELECT_*"ç221
https://website.com?name=23+*+~33¬¬
https://website.com?name=&&%*ç"exit
https://website.com?name=count(*)#@|@

And the user keeps executing it, let's say 100 requests per minute. Is there a way to detect this and ban the users IP address immediately in Spring Boot?

1

There are 1 best solutions below

2
Yogesh Prajapati On

There are many ways to do it, but I suggest to go for https://github.com/MarcGiffing/bucket4j-spring-boot-starter

It has an option to limit the rate based on remote IP address.