How to configure nginx to limit the access frequency of the same IP

WBOY
Release: 2023-05-13 19:04:18
forward
2591 people have browsed it

1. Add the following code to http{} in nginx.conf:

limit_conn_zone $binary_remote_addr zone=perip:10m;

limit_conn_zone $server_name zone=perserver:10m;
Copy after login

2. Configure server{ on websites that need to limit the number of concurrencies and download bandwidth. } Add the following code:

limit_conn perip 2;

limit_conn perserver 20;

limit_rate 100k;
Copy after login

Additional explanation of the parameters:

$binary_remote_addr is to limit the same client ip address;

$ server_name is to limit the maximum number of concurrent connections on the same server;

limit_conn is to limit the number of concurrent connections;

limit_rate is to limit the download speed;

The above is the detailed content of How to configure nginx to limit the access frequency of the same IP. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
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!