撠潸頛瘥頛擃隡箸剁臭誑閮剖瘥銝雿雿輻刻臭蝙函鞈皞銝嚗靘憒憭折蝺詻蝺餌嚗瘥蝘瘥蝺甈⊥賂隞亙銝頛摨艾
/ r2 W2 J) J9 E& V1 M6 p! { T" |3 n0 n. Y9 J* v( I( E' t+ Q
憭折蝺亥嗅憭折蝺賂擐閬雿輻 limit_conn_zone 摰蝢拐 key zone 賂- limit_conn_zone $binary_remote_addr zone=addr:10m;
銴鋆賭誨蝣 隤芣:9 N. m4 O A# i
摰蝢拐 addr zone嚗蝛粹憭批 10MB嚗worker 銵蝔雿輻券 zone 蝵桃曹澈閮園蝛粹靘脣 key 閮詨潦雿輻 $binary_remote_addr 靘雿箏斗瑚皞 IP 靘嚗key嚗嚗雿輻券鈭脖霈訾雿 key 臬箏頝銝祉摮銝脫韏瑚嚗瘥頛蝛粹嚗憒 zone 蝵桃曹澈閮園蝛粹典鈭嚗隡箸典停 503嚗Service Temporarily Unavailable嚗航炊閮胯8 @" [; G" k5 ?1 J4 h, b
* K# N% R! K: b8 _& k5 g+ U
- @( V/ \' B# y, p( V" f亥雿輻 limit_conn 摰銝 IP 臭誑閮梁憭折蝺賂1 b. O" r! D ], F3 l2 {
- location /download/ {
- P( F, T& N. v2 f - limit_conn addr 5;6 m+ M; V1 u1 M7 O
- }
銴鋆賭誨蝣 B) C3 r/ t/ T: Z) ~' M( B* X8 ?
1 `" w, g& B X$ Z) f
臬 server 畾菟撠Domain銝撠銝靘桅靘園蝺5 J* Y! d3 `3 s" I h1 t* m% ?
- .
# d% b. a7 H/ W1 z0 n; s$ k ] - .- S3 T3 J0 K: n( T9 I! g
- .& z4 x% |, Q" m. D' e
- server {" d* N+ w' y7 R
- ., P( X! x: ^, T3 z3 ~
- .
' a7 ~5 \4 |$ s' m - limit_conn addr 5;
9 W, [& O8 p' u - .
r E( |: u1 ?2 i$ W( b2 ^ - .) u9 n/ Z4 z3 s8 v. e
- }
銴鋆賭誨蝣 2 c) G y6 ~7 `/ O" @5 Q2 z: A( i
7 J0 Z3 R2 o7 y3 {5 O/ c" c0 L
蝺餌(瘥IP桐蝺)5 e# D$ G7 j3 S
& C5 M) F; F) {+ L; l
& v( \6 u& u; E8 f" G- H亥園蝺餌嚗擐銋臭璅閬 limit_req_zone 摰蝢 key zone 賂
8 ]# P' L, H w& m( a- limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
銴鋆賭誨蝣 * S! p* ]0 k5 R" ]$ b
支摰蝢 zone 蝔梯憭批銋憭嚗銝鈭銝 rate 摰蝺餌銝嚗桐臭誑雿輻冽蝘蝺甈⊥賂r/s嚗舀蝺甈⊥賂r/m嚗嚗r盍equest嚗靘憒亥摰瘥銝航 30 甈⊿蝺嚗閮剖 30r/m& D( C/ ^' {7 \
C/ x& M; a, t4 S/ U
+ W" J9 L8 b; B
嗅券閬園蝺餌唳孵銝 limit_req 閮剖嚗
$ }. I: _: }/ ]& x9 U7 B- location /download/ {
) z P9 Q% C" r* c4 R! E - limit_req zone=one burst=5;
4 Z4 @- l% W2 c& G - }
銴鋆賭誨蝣
% `2 x2 |0 B, V8 _臬 server 畾菟撠Domain銝撠銝靘桅靘園餌
; f/ x, k8 ^: X t+ y$ s" @- .
: W/ q; ?. b. [$ R+ e - .6 `! x/ `2 _% G) d" v3 H
- .
# f& G: L9 j0 z* f - server {
" `$ ^- @- u" L - .
9 @: B" _5 N5 ]7 z - ./ m x1 e& @. k/ ~/ e
- <span style="font-family: Tahoma;">limit_req zone=one burst=5;</span>
" N( { I5 }& t+ F: Z0 H - .
$ ^, F7 R! Z9 v' Z( e$ r - .
4 H+ L2 g: E7 T6 } - }
銴鋆賭誨蝣 5 q! c1 q7 ]% D; f% U9 B0 i
7 C/ J9 u& Z" \3 E% [5 \% \% f
蝯隢:* f! I' n$ f. k G1 e! s
5 j- N8 A9 q, ]9 ^撠潔誑銝閮剖臭誑脫迫擏剖恥餅隞亙鈭敹銋敺閰血瘨雿∠餃祝
2 X% t& W Q! X1 B0 t0 w/ e$ ^, R" i/ ]& v- m
嗡隢 :
* c* u7 \* `6 k( ?8 xhttps://blog.gtwang.org/linux/ng ... address-tutorial/2/
5 V1 |& m9 d4 ohttp://www.nginx.cn/446.html& u* J v7 N7 F' H" o
! \. L) t/ v; |% X6 z
|
|