http {
limit_conn_zone $binary_remote_addr zone=conn_zone:10m;
limit_req_zone $binary_remote_addr zone=req_zone:10m rate=1r/s;
# other configuration
}
server {
listen 80;
server_name example.com;
# Limit the maximum number of connections for a single client IP to 2
limit_conn conn_zone 2;
# Limit a single client IP to initiate a maximum of 1 request within 1s
limit_req zone=req_zone burst=5;
# Calculate the cumulative request traffic of the client IP, and limit the cumulative request traffic to 1GB
set $limit_rate 128k;
limit_rate_after 500M;
limit_rate 1m;
# Other processing logic
}
Post comment 取消回复