🔒 Closed Nginx config to limit each IP?

Status
Not open for further replies.
To limit each IP to a maximum of 30 connections per minute in Nginx, you can use the limit_conn_zone and limit_conn directives. Here's an example configuration:

Code:
http {
  limit_conn_zone $binary_remote_addr zone=addr:10m;
  
  server {
    ...
    
    location / {
      limit_conn addr 30;
      
      ...
    }
  }
}

Explanation:
  • limit_conn_zone defines the shared memory zone used to store connection tracking data. The $binary_remote_addr variable is used as the identifier for each client IP address, and the zone size is set to 10m (you can adjust the size to suit your needs).
  • limit_conn specifies the maximum number of connections per IP address within the specified shared memory zone. In this case, addr is the name of the connection zone defined earlier, and 30 is the maximum number of connections allowed.

This configuration will limit each client IP to a maximum of 30 connections per minute for all requests to the specified location. You can adjust the limits to suit your needs, and you can apply the limit_conn directive to other locations as needed.
 
Status
Not open for further replies.

About this Thread

  • 7
    Replies
  • 1K
    Views
  • 7
    Participants
Last reply from:
Darken Summer

Online now

Members online
357
Guests online
2,008
Total visitors
2,365

Forum statistics

Threads
2,277,866
Posts
28,979,353
Members
1,229,122
Latest member
simpletic
Back
Top