撠潸頛瘥頛擃隡箸剁臭誑閮剖瘥銝雿雿輻刻臭蝙函鞈皞銝嚗靘憒憭折蝺詻蝺餌嚗瘥蝘瘥蝺甈⊥賂隞亙銝頛摨艾
: ^ q" Y# @+ y, _' o0 N! ^* P" t9 U8 U; Q0 h& G
憭折蝺亥嗅憭折蝺賂擐閬雿輻 limit_conn_zone 摰蝢拐 key zone 賂- limit_conn_zone $binary_remote_addr zone=addr:10m;
銴鋆賭誨蝣 隤芣:& J9 A& q! r* a+ B
摰蝢拐 addr zone嚗蝛粹憭批 10MB嚗worker 銵蝔雿輻券 zone 蝵桃曹澈閮園蝛粹靘脣 key 閮詨潦雿輻 $binary_remote_addr 靘雿箏斗瑚皞 IP 靘嚗key嚗嚗雿輻券鈭脖霈訾雿 key 臬箏頝銝祉摮銝脫韏瑚嚗瘥頛蝛粹嚗憒 zone 蝵桃曹澈閮園蝛粹典鈭嚗隡箸典停 503嚗Service Temporarily Unavailable嚗航炊閮胯3 E8 Y5 n# I; j2 P$ G
8 K& y" Q O, h$ [2 i/ d
: b) _" {4 I3 t) j8 Z& D亥雿輻 limit_conn 摰銝 IP 臭誑閮梁憭折蝺賂" l2 W9 x( [ |0 E
- location /download/ {& M* v/ }' g$ E1 J/ `9 `
- limit_conn addr 5;& y, E: T9 Z9 Z/ w% d% R+ Y
- }
銴鋆賭誨蝣
" k) D2 y( o% ]: V
4 E( Q# A9 J! r$ k$ L& i8 ^臬 server 畾菟撠Domain銝撠銝靘桅靘園蝺
$ o+ ^4 h+ N$ ]$ ]- .
0 A' Z6 _. H) H - .) q2 \, g+ O# c1 V
- .. ?- ^# v' ^3 Q2 {- E, U
- server { ]5 @/ k' i4 Z: k
- .. i+ v' w6 a$ {% ?
- .
/ e2 P7 v0 q& ^) k& @" E$ h - limit_conn addr 5; D! {& W4 ?+ @( J" ?
- .% ^8 P+ B& X7 K! Y" [! C
- .
& o# ]4 R1 Z: i, i: ] - }
銴鋆賭誨蝣
; ?5 e5 h7 }6 D- \( y8 W" E# D3 `! V& C* [( a" A( u" W
蝺餌(瘥IP桐蝺)
+ b% K8 f5 G8 ~. }1 c( I8 f. F4 v8 k5 A. b
7 T2 [& F* }5 S, v& S# K( v" _: s
亥園蝺餌嚗擐銋臭璅閬 limit_req_zone 摰蝢 key zone 賂
e$ H6 F. s6 O/ |7 f8 m' W9 L- limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
銴鋆賭誨蝣
5 ?0 w% |6 Y! d: {. V支摰蝢 zone 蝔梯憭批銋憭嚗銝鈭銝 rate 摰蝺餌銝嚗桐臭誑雿輻冽蝘蝺甈⊥賂r/s嚗舀蝺甈⊥賂r/m嚗嚗r盍equest嚗靘憒亥摰瘥銝航 30 甈⊿蝺嚗閮剖 30r/m
7 q- R& T2 z# S3 j+ T' a! l/ J. } w% y- N4 k) L8 z2 }
+ o' W& K. q C# s; ~嗅券閬園蝺餌唳孵銝 limit_req 閮剖嚗
3 o% b7 [' S; @; f: ~% ]0 ^8 s- location /download/ {
" |4 n1 Y+ v/ [ - limit_req zone=one burst=5;
3 T1 A0 i% d' V - }
銴鋆賭誨蝣 3 L! c0 C! Y# r) o- l( P
臬 server 畾菟撠Domain銝撠銝靘桅靘園餌
5 C: {& m, W" W5 j4 G6 K2 V) j- r- .; }: P/ U3 t2 C* h
- .
. p( J; v) w2 Q8 p3 R - .) t" L6 L% W" Z! B2 F; H
- server {
8 @( Z, u0 f7 D% X+ T - .
8 m- j* o' v2 Q2 M - .
' n4 H7 G* k2 q6 y$ B3 v - <span style="font-family: Tahoma;">limit_req zone=one burst=5;</span>( d0 y5 v" C2 }3 \4 e
- .1 B- T5 R: A' H" g' {
- .
$ W9 H5 {1 W8 o4 M7 z* B - }
銴鋆賭誨蝣
9 o% Z- |. \# W- [" v2 |: A& I# m b1 ^' f1 h7 @
蝯隢:% C" ?+ H/ o0 h& k
/ P2 r1 P6 u7 S撠潔誑銝閮剖臭誑脫迫擏剖恥餅隞亙鈭敹銋敺閰血瘨雿∠餃祝
$ N6 J5 c' x7 U9 g& T: L% J" n0 R( g. ?) x
嗡隢 :
" Q4 ~' Z0 ?% o6 n( D; k! I/ ~https://blog.gtwang.org/linux/ng ... address-tutorial/2/6 l. z7 |& r3 B& X6 _; Y
http://www.nginx.cn/446.html
6 u1 J7 f, q' ^1 k% E' a6 m% v# |" ~7 R( z& B/ l6 L! S, G
|
|