Skip to content

Commit b5fdafe

Browse files
committed
first test succ
1 parent d034448 commit b5fdafe

File tree

6 files changed

+452
-11
lines changed

6 files changed

+452
-11
lines changed

README

Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
Name
2+
nginx_http_upstream_check_module - support upstream health check with Nginx
3+
4+
Status
5+
This module is at its very early phase of development and considered
6+
highly experimental. But you're encouraged to test it out on your side
7+
and report any quirks that you experience.
8+
9+
We need your help! If you find this module useful and/or interesting,
10+
please consider joining the development!
11+
12+
Synopsis
13+
http {
14+
15+
listen 80;
16+
17+
upstream cluster {
18+
# simple round-robin
19+
server 127.0.0.1:3306;
20+
server 127.0.0.1:1234;
21+
22+
check interval=3000 rise=2 fall=5 timeout=1000;
23+
24+
#check interval=3000 rise=2 fall=5 timeout=1000 type=ssl_hello;
25+
26+
#check interval=3000 rise=2 fall=5 timeout=1000 type=http;
27+
#check_http_send "GET / HTTP/1.0\r\n\r\n";
28+
#check_http_expect_alive http_2xx http_3xx;
29+
}
30+
31+
server {
32+
listen 8888;
33+
34+
location /{
35+
proxy_pass cluster;
36+
}
37+
38+
location /status {
39+
check_status;
40+
}
41+
}
42+
}
43+
44+
Description
45+
46+
Directives
47+
48+
check
49+
syntax: *check interval=milliseconds [fall=count] [rise=count]
50+
[timeout=milliseconds] [type=tcp|ssl_hello|smtp|mysql|pop3|imap]*
51+
52+
default: *none, if parameters omitted, default parameters are
53+
interval=30000 fall=5 rise=2 timeout=1000*
54+
55+
context: *upstream*
56+
57+
description: Add the health check for the upstream servers. At present,
58+
the check method is a simple tcp connect.
59+
60+
The parameters' meanings are:
61+
62+
* *interval*: the check request's interval time.
63+
64+
* *fall*(fall_count): After fall_count check failures, the server is
65+
marked down.
66+
67+
* *rise*(rise_count): After rise_count check success, the server is
68+
marked up.
69+
70+
* *timeout*: the check request's timeout.
71+
72+
* *type*: the check protocol type:
73+
74+
1. *tcp* is a simple tcp socket connect and peek one byte.
75+
76+
2. *ssl_hello* sends a client ssl hello packet and receives the
77+
server ssl hello packet.
78+
79+
3. *http* sends a http requst packet, recvives and parses the http
80+
response to diagnose if the upstream server is alive.
81+
82+
4. *smtp* sends a smtp requst packet, recvives and parses the smtp
83+
response to diagnose if the upstream server is alive. The
84+
response begins with '2' should be an OK response.
85+
86+
5. *mysql* connects to the mysql server, recvives the greeting
87+
response to diagnose if the upstream server is alive.
88+
89+
6. *pop3* recvives and parses the pop3 response to diagnose if the
90+
upstream server is alive. The response begins with '+' should be
91+
an OK response.
92+
93+
7. *imap* connects to the imap server, recvives the greeting
94+
response to diagnose if the upstream server is alive.
95+
96+
check_http_send
97+
syntax: *check_http_send http_packet*
98+
99+
default: *"GET / HTTP/1.0\r\n\r\n"*
100+
101+
context: *upstream*
102+
103+
description: If you set the check type is http, then the check function
104+
will sends this http packet to check the upstream server.
105+
106+
check_http_expect_alive
107+
syntax: *check_http_expect_alive [ http_2xx | http_3xx | http_4xx |
108+
http_5xx ]*
109+
110+
default: *http_2xx | http_3xx*
111+
112+
context: *upstream*
113+
114+
description: These status codes indicate the upstream server's http
115+
response is ok, the backend is alive.
116+
117+
check_smtp_send
118+
syntax: *check_smtp_send smtp_packet*
119+
120+
default: *"HELO smtp.localdomain\r\n"*
121+
122+
context: *upstream*
123+
124+
description: If you set the check type is smtp, then the check function
125+
will sends this smtp packet to check the upstream server.
126+
127+
check_smtp_expect_alive
128+
syntax: *check_smtp_expect_alive [smtp_2xx | smtp_3xx | smtp_4xx |
129+
smtp_5xx]*
130+
131+
default: *smtp_2xx*
132+
133+
context: *upstream*
134+
135+
description: These status codes indicate the upstream server's smtp
136+
response is ok, the backend is alive.
137+
138+
check_shm_size
139+
syntax: *check_shm_size size*
140+
141+
default: *(number_of_checked_upstream_blocks + 1) * pagesize*
142+
143+
context: *tcp*
144+
145+
description: If you store hundreds of serveres in one upstream block,
146+
the shared memory for health check may be not enough, you can enlarged
147+
it by this directive.
148+
149+
check_status
150+
syntax: *check_status*
151+
152+
default: *none*
153+
154+
context: *location*
155+
156+
description: Display the health checking servers' status by HTTP. This
157+
directive is set in the http block.
158+
159+
ngx_tcp_upstream_ip_hash_module
160+
161+
Installation
162+
163+
Compatibility
164+
* My test bed is 0.7.65 and 0.8.34.
165+
166+
Notes
167+
The http_response_parse.rl and smtp_response_parse.rl are ragel
168+
(<http://www.complang.org/ragel/>) scripts , you can edit the script and
169+
compile it like this:
170+
171+
$ ragel -G2 http_response_parse.rl
172+
$ ragel -G2 smtp_response_parse.rl
173+
174+
TODO
175+
176+
Known Issues
177+
* Developing
178+
179+
Changelogs
180+
181+
Authors
182+
Weibin Yao(姚伟斌) *yaoweibin at gmail dot com*
183+
184+
Copyright & License
185+
This README template copy from agentzh (<http://github.com/agentzh>).
186+
187+
This module is borrowed the design of Jack Lindamood's healthcheck
188+
module healthcheck_nginx_upstreams
189+
(<http://github.com/cep21/healthcheck_nginx_upstreams>);
190+
191+
This module is licensed under the BSD license.
192+
193+
Copyright (C) 2010 by Weibin Yao <[email protected]>.
194+
195+
All rights reserved.
196+
197+
Redistribution and use in source and binary forms, with or without
198+
modification, are permitted provided that the following conditions are
199+
met:
200+
201+
* Redistributions of source code must retain the above copyright
202+
notice, this list of conditions and the following disclaimer.
203+
204+
* Redistributions in binary form must reproduce the above copyright
205+
notice, this list of conditions and the following disclaimer in the
206+
documentation and/or other materials provided with the distribution.
207+
208+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
209+
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
210+
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
211+
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
212+
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
213+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
214+
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
215+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
216+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
217+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
218+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
219+

0 commit comments

Comments
 (0)