撠潸頛瘥頛擃隡箸剁臭誑閮剖瘥銝雿雿輻刻臭蝙函鞈皞銝嚗靘憒憭折蝺詻蝺餌嚗瘥蝘瘥蝺甈⊥賂隞亙銝頛摨艾2 B/ ]0 J5 U0 y3 l5 `0 p
T- Z! ~, o, p8 [- G2 p. b憭折蝺亥嗅憭折蝺賂擐閬雿輻 limit_conn_zone 摰蝢拐 key zone 賂- limit_conn_zone $binary_remote_addr zone=addr:10m;
銴鋆賭誨蝣 隤芣:
; Y9 P' t7 y5 z. n$ k摰蝢拐 addr zone嚗蝛粹憭批 10MB嚗worker 銵蝔雿輻券 zone 蝵桃曹澈閮園蝛粹靘脣 key 閮詨潦雿輻 $binary_remote_addr 靘雿箏斗瑚皞 IP 靘嚗key嚗嚗雿輻券鈭脖霈訾雿 key 臬箏頝銝祉摮銝脫韏瑚嚗瘥頛蝛粹嚗憒 zone 蝵桃曹澈閮園蝛粹典鈭嚗隡箸典停 503嚗Service Temporarily Unavailable嚗航炊閮胯, }; ?/ w7 X4 ^5 b# m, d) M
& A' F: ]: K% c! ` O
( D' B0 t) _8 |1 i3 T G亥雿輻 limit_conn 摰銝 IP 臭誑閮梁憭折蝺賂
. |' O$ e k/ B( W( e' [- location /download/ {
5 o: u; Q$ p' Q# @0 p6 C0 u - limit_conn addr 5;
4 r! ?+ Y8 S0 `$ V' z- T2 } - }
銴鋆賭誨蝣 $ e5 p, J; }! g
, d; z& j# ? f. ]8 n$ W臬 server 畾菟撠Domain銝撠銝靘桅靘園蝺
8 k$ A \# }! T( g5 C& m- .
9 I7 G+ x( K( i+ _, B: P - ." v' x& p0 Y6 Q& g
- .
- z* t) l( j9 X4 z/ ~* [! e - server {' L, b1 K# v; m1 e
- .4 h" ]' Z+ o0 \; A. {! `2 x9 I
- .
+ l. Z$ G- M& N1 x - limit_conn addr 5;; Q/ \7 r7 x m$ ?; W" B* S3 F
- .! o3 b# p) s8 w9 P
- .& [7 i; ?# z$ U; A
- }
銴鋆賭誨蝣 4 M& u1 m, L% }
6 o' K( y; [# u+ v$ ~: c- S/ I% E
蝺餌(瘥IP桐蝺)$ _. X' {: F: ?. W
8 [) |7 k! Z# o2 `- ?. n
0 p# { v; V& u3 G6 L# a亥園蝺餌嚗擐銋臭璅閬 limit_req_zone 摰蝢 key zone 賂, k7 Q, Z, l& e6 d' ?$ q* s/ S
- limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
銴鋆賭誨蝣
" _& Q4 e }5 [) R! c- O9 }% C支摰蝢 zone 蝔梯憭批銋憭嚗銝鈭銝 rate 摰蝺餌銝嚗桐臭誑雿輻冽蝘蝺甈⊥賂r/s嚗舀蝺甈⊥賂r/m嚗嚗r盍equest嚗靘憒亥摰瘥銝航 30 甈⊿蝺嚗閮剖 30r/m
/ _% }; q; ~6 _5 H& ~2 G. g7 ^6 c8 n2 {8 j
9 c* Z7 C1 W6 p8 N5 b0 K
嗅券閬園蝺餌唳孵銝 limit_req 閮剖嚗
- z( H0 d& E+ L- location /download/ {
5 p5 W& |) A1 ^$ C - limit_req zone=one burst=5;
* }0 I1 J- T j9 M - }
銴鋆賭誨蝣
+ o: f; O' d' ?! S9 a臬 server 畾菟撠Domain銝撠銝靘桅靘園餌
# G1 M5 }! A: B! z( ]- .
+ L4 X7 }, m( ? - .% `) y+ f, q- ^$ t
- .
$ O ?( x7 S2 |3 K - server {, A3 N* N: v$ c& P1 F8 O) _- m) c
- .3 y. ~! V- b( V; r) j& c
- .
" q) E6 n E( Z" P8 _* p - <span style="font-family: Tahoma;">limit_req zone=one burst=5;</span>( W B& s% B& t7 U% R# _, Q
- .! e; Y/ b. X2 I. i. O9 ?& j
- .
4 ]2 x$ H8 _4 ^, i7 Y6 t4 ` - }
銴鋆賭誨蝣
9 U' \" V ?2 W$ X) F. C& y
. b/ v ~4 F5 f2 ]) H蝯隢:
1 h, F, }$ p9 L R/ K) F& o: D% ^+ R! Z+ M' l3 h2 x% J3 |( r
撠潔誑銝閮剖臭誑脫迫擏剖恥餅隞亙鈭敹銋敺閰血瘨雿∠餃祝
! t6 T$ l: [: q* M5 q
" Q' a! T% w/ m/ T/ j; A嗡隢 :8 {& Y0 u- c. J0 O3 t' M0 K
https://blog.gtwang.org/linux/ng ... address-tutorial/2/
( \$ X; b9 h( U. A' yhttp://www.nginx.cn/446.html) O8 D; ~9 z8 h+ P: W& W; F
+ m- C" ~9 E3 r/ C1 }. J$ w; y9 k7 i3 c% U
|
|