Junior — Middle
What types of limiting constraints can be set in NGINX settings?
sobes.tech AI
Answer from AI
In NGINX, you can set various limiting restrictions to control load and protect the server. The main types of restrictions:
-
limit_req — limits the number of requests from a single client over a certain period (rate limiting). It helps protect against DDoS and excessive requests.
-
limit_conn — limits the number of simultaneous connections from a single client or at the server level.
-
limit_rate — limits the data transfer rate to the client (for example, to limit the speed of file delivery).
-
limit_zone — a memory area for storing the state of limits (used together with limit_req and limit_conn).
Example of a request limit configuration:
limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
server {
location /api/ {
limit_req zone=one burst=5 nodelay;
}
}