How to block spamming IP coming to your environment in Tomcat?

There is a case that ton of requests are rushing into your Tomcat webapps, mostly because your service becomes rock star, the bug of your new implementation cause user's "refresh", or maybe something else.

For non-heavy requests which hits cached data most of the time would be fine for those cases, but other types of requests like new login account creation, real-time status query like server status, place order, etc are highly related to database call, and mostly will not be cached. Those calls can exhaust your Tomcat webapps JDBC connection pool too fast and make the service unrecoverable.
Implementing throttling in app would be definitely helpful in this case, but even the solution might need some time to coding. There are other ways you can filter spamming IP in OS level using iptables things or Apache mod_xxx plugin, etc, but probably the easiest and fastest way to block those spamming(well, at least to you) IP would be adding following "Valve" configuration into Tomcat's server.xml.
<Valve className="org.apache.catalina.valves.RemoteAddrValve" deny="xx.x.xx.xxx" />
This set up need to be located under <Engine> section, and at the same level with "Host". ( chanse xx.x.xx.xxx to the IP which you want to block).
You can either use "deny" or "allow" for Valve configuration, but "deny" would be what you ant to use at this moment.
For more information about Valve configuration in Tomcat, check http://tomcat.apache.org/tomcat-7.0-doc/config/valve.html

댓글 없음:

댓글 쓰기

UIUC MCS-DS첫번째 날 시작

오늘이 학생들에게 UIUC MCS-DS 의 코세라 수업이 할당되고 공식적으로 일정이 시작된 (Aug 27, 2018) 첫날이다. 아직까지 기존에 공개되어 있어 진도를 나갈 수 있었던 specialization 클래스들의 진행상황이 MCS-DS 과정으...