我已经让 Varnish 缓存与 PHP Captcha 一起使用,但我还不
明白如何设置触发限制。
在每小时(或每分钟)限制如此多的请求之后,将
发送验证码输入。
我有它的工作,但想了解我如何改变 req/s 限制。
以下是来自的代码:http:
//drcarter.info/2010/04/how-fighting-against-scraping-using-varnish-vcl-inline-c-memcached/
这段代码对我说了什么?
if (rc == MEMCACHED_SUCCESS) {
uint64_t intval;
rc= memcached_increment(memc, key, strlen(key), (uint64_t)1, &intval);
if (rc != MEMCACHED_SUCCESS)
rc= memcached_set(memc, key, strlen(key), "1", 1, (time_t)60, (uint32_t)0);
else
if (intval>30) {
VRT_SetHdr(sp, HDR_REQ, "\013X-Scraping:", "1", vrt_magic_string_end);
syslog(LOG_INFO, "Scraping detected from %s",VRT_IP_string(sp, VRT_r_client_ip(sp)));
if (intval<300)
rc= memcached_set(memc, key, strlen(key), "500", 3, (time_t)3600, (uint32_t)0);
}
您的建议将不胜感激。
谢谢!