原配置:
http { ...... limit_conn_zone $binary_remote_addr zone=one:10m; limit_req_zone $binary_remote_addr zone=fifa:10m rate=5r/s; ...... server { ...... limit_conn one 5; limit_req zone=fifa burst=100; ...... }}
|-------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 1 2 3 4 5 6 7 8 9 10 11 | http { ...... limit_conn_zone $binary_remote_addr zone=one:10m; limit_req_zone $binary_remote_addr zone=fifa:10m rate=5r/s; ...... server { ...... limit_conn one 5; limit_req zone=fifa burst=100; ...... }} |
白名单配置:
http { ...... geo $whiteiplist { default 1; 127.0.0.1 0; 10.10.0.0/24 0; } map $whiteiplist $limit { 1 $binary_remote_addr; 0 ""; } limit_conn_zone $limit zone=one:10m; limit_req_zone $limit zone=fifa:10m rate=5r/s; ...... server { ...... limit_conn one 5; limit_req zone=fifa burst=100; ...... }}
|----------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | http { ...... geo $whiteiplist { default 1; 127.0.0.1 0; 10.10.0.0/24 0; } map $whiteiplist $limit { 1 $binary_remote_addr; 0 ""; } limit_conn_zone $limit zone=one:10m; limit_req_zone $limit zone=fifa:10m rate=5r/s; ...... server { ...... limit_conn one 5; limit_req zone=fifa burst=100; ...... }} |
说明: