撠潸頛瘥頛擃隡箸剁臭誑閮剖瘥銝雿雿輻刻臭蝙函鞈皞銝嚗靘憒憭折蝺詻蝺餌嚗瘥蝘瘥蝺甈⊥賂隞亙銝頛摨艾
6 C9 `4 z I- q9 c) b. O' i w5 K0 t2 S; Q) m
憭折蝺亥嗅憭折蝺賂擐閬雿輻 limit_conn_zone 摰蝢拐 key zone 賂- limit_conn_zone $binary_remote_addr zone=addr:10m;
銴鋆賭誨蝣 隤芣:
6 A& f3 J' t: [5 Z( |' R; V摰蝢拐 addr zone嚗蝛粹憭批 10MB嚗worker 銵蝔雿輻券 zone 蝵桃曹澈閮園蝛粹靘脣 key 閮詨潦雿輻 $binary_remote_addr 靘雿箏斗瑚皞 IP 靘嚗key嚗嚗雿輻券鈭脖霈訾雿 key 臬箏頝銝祉摮銝脫韏瑚嚗瘥頛蝛粹嚗憒 zone 蝵桃曹澈閮園蝛粹典鈭嚗隡箸典停 503嚗Service Temporarily Unavailable嚗航炊閮胯( F5 C) O. E$ H3 h
+ T" G' ]2 ~6 R/ C( |
$ M; ?5 r. w+ U9 @! W亥雿輻 limit_conn 摰銝 IP 臭誑閮梁憭折蝺賂6 n, L9 F( J0 L0 ?6 c5 k9 }
- location /download/ {
/ G( D( @$ B; ]: n; o6 J! I! q - limit_conn addr 5;2 R& {: w' ^0 ^2 G) E6 }4 o7 ]
- }
銴鋆賭誨蝣
/ R; g4 Y" Z% O i* L6 D5 k
) |* H8 c7 j% g! z臬 server 畾菟撠Domain銝撠銝靘桅靘園蝺0 E! B6 s0 D4 X4 D" _; u
- .
6 z7 Y! v6 e* v3 ]1 T - .
: f. H% H! X- p0 x: ? U5 K - .
; K" r! l0 S" D1 z7 A$ I6 b: l2 \/ u - server {4 v" v# G7 ]) E q+ s4 A4 K
- .
8 X/ S% ]5 C7 y% ^8 } - .
# h' C% A' z$ M6 u - limit_conn addr 5;
% t# O# A8 ?+ R" {+ {" i4 n4 j7 A - .% t( z0 c+ n% M1 C" x
- .; g" z$ \7 d5 C- t1 f
- }
銴鋆賭誨蝣 : l ?0 o. `- h: i2 r
4 M: a, ] I% V$ y0 P% n" U蝺餌(瘥IP桐蝺). @' t0 I; N6 s( }8 H# l8 S; h
9 w+ @* D! v0 H1 P: Q2 I% Y( E, W( F( p
亥園蝺餌嚗擐銋臭璅閬 limit_req_zone 摰蝢 key zone 賂/ V5 r& G+ Q1 ?% ]
- limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
銴鋆賭誨蝣 0 n8 [* l& p3 L/ w
支摰蝢 zone 蝔梯憭批銋憭嚗銝鈭銝 rate 摰蝺餌銝嚗桐臭誑雿輻冽蝘蝺甈⊥賂r/s嚗舀蝺甈⊥賂r/m嚗嚗r盍equest嚗靘憒亥摰瘥銝航 30 甈⊿蝺嚗閮剖 30r/m
6 ^8 p3 }9 Z: C' v, v4 O) w0 ^, p1 u' i; g4 e! b F o$ |- h
, n. j* {' e, |1 z4 a! s
嗅券閬園蝺餌唳孵銝 limit_req 閮剖嚗
% D0 C3 D) A0 {( K- ]2 G7 ?- location /download/ {
7 l$ h4 {1 G E+ f* i, W/ C - limit_req zone=one burst=5;
) R* d$ S( ?+ |) V _7 B; Q- F' E" l: l, w - }
銴鋆賭誨蝣 1 o; e2 z, { E; e$ }; F: g
臬 server 畾菟撠Domain銝撠銝靘桅靘園餌 b1 c5 Z; w* Q& F6 m6 m# ^* w* r
- ." K+ ^" ?- {& _* {$ N/ K6 H
- .7 G1 D( U8 a* D5 q9 s$ P' h
- .
9 C5 P4 l2 J* p+ G - server {* {( V& ~% ~" A
- .
7 f; v" h+ w3 Y3 t" q' { - .
6 m( ^" A& \. ^2 k' g/ c; j - <span style="font-family: Tahoma;">limit_req zone=one burst=5;</span>; `* s* ^3 V2 H$ k2 a( E" p6 Y
- .2 ^* P% Q: j9 P! I
- .
" m) v+ y, v, K( ^) b - }
銴鋆賭誨蝣 8 X0 \7 O* v, P3 p. ~3 l
0 K: E9 n6 ]* H8 t: |
蝯隢:
! ?+ [- g P \/ z
0 I; L* g% N: b5 g6 W+ A撠潔誑銝閮剖臭誑脫迫擏剖恥餅隞亙鈭敹銋敺閰血瘨雿∠餃祝
7 B! E1 o! ]7 @3 S
3 ]: z5 L4 e# } D7 W) M. o嗡隢 :* a2 u3 l U V, C5 a. @
https://blog.gtwang.org/linux/ng ... address-tutorial/2/) Q& r' L9 h1 |: t' w6 @# G
http://www.nginx.cn/446.html
4 l. h2 n% R3 E( p9 }8 @5 B R4 b* U, l+ g8 D2 D+ m0 j
|
|