ChsHttpLimitZoneModule
Contents |
[edit] ngx_http_limit_zone_module
鏈ā鍧楀彲浠ラ拡瀵规潯浠讹紝杩涜浼氳瘽鐨勫苟鍙戣繛鎺ユ暟鎺у埗銆傦紙渚嬪锛氶檺鍒舵瘡涓狪P鐨勫苟鍙戣繛鎺ユ暟銆傦級
__閰嶇疆绀轰緥__
http { : limit_zone one $binary_remote_addr 10m; : ... : server { : ... : location /download/ { : limit_conn one 1; : }
[edit] 鎸囦护
- [#limit_zone limit_zone]
- [#limit_conn limit_conn]
[edit] limit_zone
璇硶锛 limit_zone zone_name $variable the_size
榛樿鍊硷細 no
浣滅敤鍩燂細 http
鏈寚浠ゅ畾涔変簡涓涓暟鎹尯锛岄噷闈㈣褰曚細璇濈姸鎬佷俊鎭
$variable 瀹氫箟鍒ゆ柇浼氳瘽鐨勫彉閲忥紱the_size 瀹氫箟璁板綍鍖虹殑鎬诲閲忋
渚嬪瓙锛
limit_zone one $binary_remote_addr 10m;
瀹氫箟涓涓彨鈥渙ne鈥濈殑璁板綍鍖猴紝鎬诲閲忎负 10M锛屼互鍙橀噺 $binary_remote_addr 浣滀负浼氳瘽鐨勫垽鏂熀鍑嗭紙鍗充竴涓湴鍧涓涓細璇濓級銆
鎮ㄥ彲浠ユ敞鎰忓埌浜嗭紝鍦ㄨ繖閲屼娇鐢ㄧ殑鏄 $binary_remote_addr 鑰屼笉鏄 $remote_addr銆
$remote_addr 鐨勯暱搴︿负 7 鑷 15 bytes锛屼細璇濅俊鎭殑闀垮害涓 32 鎴 64 bytes銆 鑰 $binary_remote_addr 鐨勯暱搴︿负 4 bytes锛屼細璇濅俊鎭殑闀垮害涓 32 bytes銆
褰撳尯鐨勫ぇ灏忎负 1M 鐨勬椂鍊欙紝澶х害鍙互璁板綍 32000 涓細璇濅俊鎭紙涓涓細璇濆崰鐢 32 bytes锛夈
[edit] limit_conn
璇硶锛 limit_conn zone_name the_size
榛樿鍊硷細 no
浣滅敤鍩燂細 http, server, location
鎸囧畾涓涓細璇濇渶澶х殑骞跺彂杩炴帴鏁般 褰撹秴杩囨寚瀹氱殑鏈鍙戝苟鍙戣繛鎺ユ暟鏃讹紝鏈嶅姟鍣ㄥ皢杩斿洖 "Service unavailable" (503)銆
渚嬪瓙锛
limit_zone one $binary_remote_addr 10m; : server { : location /download/ { : limit_conn one 1; : }
瀹氫箟涓涓彨鈥渙ne鈥濈殑璁板綍鍖猴紝鎬诲閲忎负 10M锛屼互鍙橀噺 $binary_remote_addr 浣滀负浼氳瘽鐨勫垽鏂熀鍑嗭紙鍗充竴涓湴鍧涓涓細璇濓級銆 闄愬埗 /download/ 鐩綍涓嬶紝涓涓細璇濆彧鑳借繘琛屼竴涓繛鎺ャ 绠鍗曠偣锛屽氨鏄檺鍒 /download/ 鐩綍涓嬶紝涓涓狪P鍙兘鍙戣捣涓涓繛鎺ワ紝澶氳繃涓涓紝涓寰503銆