撠潸頛瘥頛擃隡箸剁臭誑閮剖瘥銝雿雿輻刻臭蝙函鞈皞銝嚗靘憒憭折蝺詻蝺餌嚗瘥蝘瘥蝺甈⊥賂隞亙銝頛摨艾
& `1 U+ X: O1 n" `, l
' A8 `* k: V, A! V! I; Q" d憭折蝺亥嗅憭折蝺賂擐閬雿輻 limit_conn_zone 摰蝢拐 key zone 賂- limit_conn_zone $binary_remote_addr zone=addr:10m;
銴鋆賭誨蝣 隤芣:' ]% Z6 K5 W# Z3 \+ q- ^
摰蝢拐 addr zone嚗蝛粹憭批 10MB嚗worker 銵蝔雿輻券 zone 蝵桃曹澈閮園蝛粹靘脣 key 閮詨潦雿輻 $binary_remote_addr 靘雿箏斗瑚皞 IP 靘嚗key嚗嚗雿輻券鈭脖霈訾雿 key 臬箏頝銝祉摮銝脫韏瑚嚗瘥頛蝛粹嚗憒 zone 蝵桃曹澈閮園蝛粹典鈭嚗隡箸典停 503嚗Service Temporarily Unavailable嚗航炊閮胯+ _+ ~0 J3 a# | m' u) k
3 X/ f ^. R. o7 p
8 _; \* n5 \. U* R亥雿輻 limit_conn 摰銝 IP 臭誑閮梁憭折蝺賂
1 C2 r. T, `3 ?: `& Y% H- location /download/ {
/ m6 d. n" P i9 }; B" H' d - limit_conn addr 5;
9 O X/ g/ X/ _4 n+ [! J/ U5 p: X - }
銴鋆賭誨蝣
K w/ E& i& Z" F/ W
3 l; }. H' z; N; m g$ v臬 server 畾菟撠Domain銝撠銝靘桅靘園蝺
1 w! D& _9 k/ w- .
$ r/ w6 X. v% m3 }. b Y - .
- l T( F% N$ f2 v" Y# Y- O - .$ [! f1 E, q1 S- f1 h( ~
- server {7 A9 G/ ?! s* e7 v; a
- .
) ^+ U* i( @) s - .
8 c! E% \+ ^2 e# ^2 P - limit_conn addr 5;7 D0 h$ w4 Y) v' m2 C. Q
- .
, f8 }- B9 C8 y- J6 |0 h: S( f - .6 d$ W% W/ ^! F6 \; W
- }
銴鋆賭誨蝣
$ g4 n: n3 S) ~: v, W
8 E& v4 j* l& p% v7 n蝺餌(瘥IP桐蝺)3 m* X8 ]+ z4 c5 ]2 f
0 H' f3 Y6 _( X6 y+ a! a
% A6 w) ?8 H1 R. m( o' ~0 C, m/ P
亥園蝺餌嚗擐銋臭璅閬 limit_req_zone 摰蝢 key zone 賂
$ k& B- P* G1 p1 B3 T" R" ?- limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
銴鋆賭誨蝣 ! f; \6 A) ~2 _4 `6 ?! q
支摰蝢 zone 蝔梯憭批銋憭嚗銝鈭銝 rate 摰蝺餌銝嚗桐臭誑雿輻冽蝘蝺甈⊥賂r/s嚗舀蝺甈⊥賂r/m嚗嚗r盍equest嚗靘憒亥摰瘥銝航 30 甈⊿蝺嚗閮剖 30r/m
2 b w4 u0 V' c: a l. z! `4 Z/ h& S5 l2 E: }: h
# d) Z' _6 k! @4 q' P
嗅券閬園蝺餌唳孵銝 limit_req 閮剖嚗
" ~$ L7 n1 o$ G2 ~- location /download/ {' h1 Y" n. M' H1 J: G- y8 n( x! \
- limit_req zone=one burst=5;
# D8 B& o+ N5 G9 I; m/ B% Y - }
銴鋆賭誨蝣
' O. n- M; s2 O! y9 J( H臬 server 畾菟撠Domain銝撠銝靘桅靘園餌, G: y6 P' o8 P8 P. H$ P3 m8 ^' N
- .1 Y# N- J3 ~" P3 S1 z- }! g s
- .
9 G2 _' ^& B. w3 s( u- t2 d - .' w$ [+ y8 {8 `5 e/ @6 |
- server {7 V7 U$ A9 `% O
- .
! x7 o0 m; G0 I/ ^) { - .
9 t/ X; h0 ~) e6 r! w/ | T$ v - <span style="font-family: Tahoma;">limit_req zone=one burst=5;</span>( B& d3 Q* k; g7 j* e m" P; E( ~
- .
+ j" G. @: v3 F$ P$ j* l( h4 q - .
# {& C4 x) e1 g7 m& s - }
銴鋆賭誨蝣
# L, P. s/ `; u y' w# Q3 q$ Q* w: T7 V; g) U; s- a% Q+ ~
蝯隢:
# v5 \! c' @2 d: t4 s( l/ \' h3 N0 C+ ^# G; O" f! s3 H, ^
撠潔誑銝閮剖臭誑脫迫擏剖恥餅隞亙鈭敹銋敺閰血瘨雿∠餃祝
: o7 ^4 d2 R' h0 i z) k4 N; M4 s3 b% C" F, |. E9 L
嗡隢 :) M3 A% x& ?2 `/ ?
https://blog.gtwang.org/linux/ng ... address-tutorial/2/
( M- @/ s/ d$ U3 R. t+ B% }http://www.nginx.cn/446.html9 `, u: r' ?- S( G" G
& }; k/ ~( Y& H
|
|