Mic*_*ner 5 ddos rate-limiting spring-boot
我想防止对我的 spring boot 2 web 应用程序的 DDOS 攻击,我遇到了框架bucket4j( bucket4j-github )。我的应用程序将在 heroku 上运行,他们建议这样做(Heroku-Link)
到现在为止还挺好。我现在正在尝试实施bucket4j,我希望在那之后,如果我F5非常快速和频繁地按下,就会发生一些事情,会发生错误或类似的事情。但是它的行为就像没有bucket4j框架一样,请求已全部得到答复。
我的目标是限制来自 ip 的速率。目前我只是从本地主机尝试过。
到目前为止我所拥有的:
pom.xml
<dependency>
<groupId>com.giffing.bucket4j.spring.boot.starter</groupId>
<artifactId>bucket4j-spring-boot-starter</artifactId>
<version>0.1.15</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>org.ehcache</groupId>
<artifactId>ehcache</artifactId>
</dependency>
<dependency><!-- Somehow I needed that since bucket4j-->
<groupId>javax.interceptor</groupId>
<artifactId>javax.interceptor-api</artifactId>
<version>1.2.2</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
应用程序属性
# CACHE
spring.cache.jcache.config=classpath:ehcache.xml
# RATE LIMIT
bucket4j.enabled=true
bucket4j.filters[0].cache-name=buckets
bucket4j.filters[0].filter-method=servlet
bucket4j.filters[0].url=/*
bucket4j.filters[0].rate-limits[0].bandwidths[0].capacity=10
bucket4j.filters[0].rate-limits[0].bandwidths[0].time=1
bucket4j.filters[0].rate-limits[0].bandwidths[0].unit=minutes
bucket4j.filters[0].rate-limits[0].expression=getRemoteAddress()
bucket4j.filters[0].rate-limits[0].bandwidths[0].fixed-refill-interval=0
bucket4j.filters[0].rate-limits[0].bandwidths[0].fixed-refill-interval-unit=minutes
Run Code Online (Sandbox Code Playgroud)
缓存文件
<config ... >
<cache alias="buckets">
<expiry><ttl unit="seconds">3600</ttl></expiry>
<heap unit="entries">1000000</heap>
</cache>
</config>
Run Code Online (Sandbox Code Playgroud)
我错过了什么,或者我是否误解了框架?谢谢你的提示。
| 归档时间: |
|
| 查看次数: |
3725 次 |
| 最近记录: |