nginx random response function
我想大声告诉你
我想大声告诉你 2017-05-16 17:25:34
0
2
462

When the client interacted with the server, there was a timing design error, which caused the server to receive more than 300,000 requests in 10 minutes. The pressure on the PHP backend increased instantly and caused it to collapse.

The current solution is that since repeated requests within a short period of time obtain the same content, requests with special parameters are directly dropped at the Nginx layer and no results are returned directly.

code show as below

shell    if ( $query_string ~ "api=(getpush|remove)")
    {
        return 200 '{"resultStatus":1,"allCount":0,"data":[]}';
        break;
    }

This solution is not perfect, for example, it only blocks 90% of requests, or it only takes effect within a specified time. I wonder if any students have similar anti-attack solutions?

我想大声告诉你
我想大声告诉你

reply all(2)
我想大声告诉你

You can consider using an upstream, setting a weight, and transferring 90% of requests to a dummy interface

伊谢尔伦

fine, make up for it yourself

nginx+lua=openresty

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!