Home >Operation and Maintenance >Nginx >How to modify nginx configuration to limit the frequency of malicious crawlers

How to modify nginx configuration to limit the frequency of malicious crawlers

PHPz
PHPzforward
2023-05-12 18:25:061176browse

The code is as follows:

#全局配置

limit_req_zone $anti_spider zone=anti_spider:10m rate=15r/m;

#某个server中

limit_req zone=anti_spider burst=30 nodelay;

if ($http_user_agent ~* “xxspider|xxbot”) {

set $anti_spider $http_user_agent;

}

If the set limit frequency is exceeded, a 503 will be given to the spider.

The above is the detailed content of How to modify nginx configuration to limit the frequency of malicious crawlers. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete