撠潸頛瘥頛擃隡箸剁臭誑閮剖瘥銝雿雿輻刻臭蝙函鞈皞銝嚗靘憒憭折蝺詻蝺餌嚗瘥蝘瘥蝺甈⊥賂隞亙銝頛摨艾
+ S: [: F) a: c% d2 r: j# U# C4 V6 r% ]2 X& k
憭折蝺亥嗅憭折蝺賂擐閬雿輻 limit_conn_zone 摰蝢拐 key zone 賂- limit_conn_zone $binary_remote_addr zone=addr:10m;
銴鋆賭誨蝣 隤芣:- `( P) `; M6 A1 `; U" g+ Q
摰蝢拐 addr zone嚗蝛粹憭批 10MB嚗worker 銵蝔雿輻券 zone 蝵桃曹澈閮園蝛粹靘脣 key 閮詨潦雿輻 $binary_remote_addr 靘雿箏斗瑚皞 IP 靘嚗key嚗嚗雿輻券鈭脖霈訾雿 key 臬箏頝銝祉摮銝脫韏瑚嚗瘥頛蝛粹嚗憒 zone 蝵桃曹澈閮園蝛粹典鈭嚗隡箸典停 503嚗Service Temporarily Unavailable嚗航炊閮胯
, G! \7 x4 R" n# s3 M% G
' c4 u8 O3 k3 y9 U( {) X' p q! ^4 E) [
亥雿輻 limit_conn 摰銝 IP 臭誑閮梁憭折蝺賂& `& b" v8 T4 Q6 S% v k
- location /download/ {: x, U: W4 s; u% n; \
- limit_conn addr 5;
3 M6 `6 C9 `( Y4 m" R - }
銴鋆賭誨蝣
0 p @$ A! o( y2 E4 i) P: k. W6 _1 c6 I3 H% ?* e/ Z
臬 server 畾菟撠Domain銝撠銝靘桅靘園蝺
5 c3 z$ o: D4 n) x X- .& j+ t4 ~8 R, O
- .
* o! g( f6 Y8 \ - .
( a1 {% i: C/ n$ Z - server {/ Q! f1 y4 e# Z; F2 u
- .
5 c$ h- [9 Z& _ - .
2 q" @( \/ j! m' r& ]5 O - limit_conn addr 5;
( C; i) K! d& m - .4 K$ m, O7 `' q9 O6 |" n7 w* t
- .
# x4 A% X8 h% Q8 D: W% x1 Y) e - }
銴鋆賭誨蝣 " \/ ]0 B1 k, N5 q
) P7 n F* G0 e* u3 H/ _蝺餌(瘥IP桐蝺)
4 ]5 @, _4 J% o# M9 d9 K5 i/ Q7 c( p( {' Z
- A. M6 |) G w) g3 Y6 x& b
亥園蝺餌嚗擐銋臭璅閬 limit_req_zone 摰蝢 key zone 賂
3 ?; t. H# t: ]. i9 X9 a- limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
銴鋆賭誨蝣
D- m5 D% P$ k; \, Y6 _ J支摰蝢 zone 蝔梯憭批銋憭嚗銝鈭銝 rate 摰蝺餌銝嚗桐臭誑雿輻冽蝘蝺甈⊥賂r/s嚗舀蝺甈⊥賂r/m嚗嚗r盍equest嚗靘憒亥摰瘥銝航 30 甈⊿蝺嚗閮剖 30r/m
9 E' @; x% t, r1 E4 ]5 e% Z7 y2 t
3 c! t T! t. Y" s) F, w1 d# j/ F/ s/ v9 h
嗅券閬園蝺餌唳孵銝 limit_req 閮剖嚗
* ]1 i5 F, ~+ Q" x$ g! D7 v- location /download/ {
% q( ], J8 r8 S+ A& A - limit_req zone=one burst=5;
% h% _/ e( _# K- T: S/ _ - }
銴鋆賭誨蝣
3 f& e }. h5 y. h$ f5 E臬 server 畾菟撠Domain銝撠銝靘桅靘園餌
) U; d' T8 W! h. d' G# `- .
4 c2 A# A2 l) a+ g% S - .
2 ]- {- Y& X& y; o4 ?; c - .
/ ^1 ^( i+ P+ l6 _ - server {2 d9 z# A/ l: c: E1 s
- .
2 e+ f5 i3 L7 T - .2 x2 R9 _1 @4 Q* y5 j- y8 g
- <span style="font-family: Tahoma;">limit_req zone=one burst=5;</span>
^) v6 A# T1 l9 w( e - .
5 i1 D9 t' q. A - .9 I p+ O' D/ Y; F8 A
- }
銴鋆賭誨蝣 6 _$ t) }$ }. I# e$ e$ f( b( \
) M: `3 F, ~5 s# T9 @2 ?3 E( f蝯隢:
5 W$ j r4 E' x7 e. W7 |8 s" {: L3 f+ D; f
撠潔誑銝閮剖臭誑脫迫擏剖恥餅隞亙鈭敹銋敺閰血瘨雿∠餃祝
' \. B! \5 m& j+ w) B6 b; O( X/ F1 W- r" t& ?, @
嗡隢 :
2 ?. E* A( k/ _1 w% B/ bhttps://blog.gtwang.org/linux/ng ... address-tutorial/2/
! T- u- \9 L, N& [2 x1 |# f- Qhttp://www.nginx.cn/446.html
) [* T/ C# P0 f+ {6 e1 O2 `# i" o' [- B' X
|
|