1diff --git src/http/modules/ngx_http_upstream_hash_module.c src/http/modules/ngx_http_upstream_hash_module.c
2index 1e2e05c..44a72e2 100644
3--- src/http/modules/ngx_http_upstream_hash_module.c
4+++ src/http/modules/ngx_http_upstream_hash_module.c
5@@ -9,6 +9,9 @@
6 #include <ngx_core.h>
7 #include <ngx_http.h>
8
9+#if (NGX_HTTP_UPSTREAM_CHECK)
10+#include "ngx_http_upstream_check_module.h"
11+#endif
12
13 typedef struct {
14     uint32_t                            hash;
15@@ -235,6 +238,15 @@ ngx_http_upstream_get_hash_peer(ngx_peer_connection_t *pc, void *data)
16             goto next;
17         }
18
19+#if (NGX_HTTP_UPSTREAM_CHECK)
20+        ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
21+            "get hash peer, check_index: %ui",
22+             peer->check_index);
23+        if (ngx_http_upstream_check_peer_down(peer->check_index)) {
24+            goto next;
25+        }
26+#endif
27+
28         if (peer->max_fails
29             && peer->fails >= peer->max_fails
30             && now - peer->checked <= peer->fail_timeout)
31@@ -535,6 +547,15 @@ ngx_http_upstream_get_chash_peer(ngx_peer_connection_t *pc, void *data)
32                 continue;
33             }
34
35+#if (NGX_HTTP_UPSTREAM_CHECK)
36+            ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
37+                "get consistent_hash peer, check_index: %ui",
38+                 peer->check_index);
39+            if (ngx_http_upstream_check_peer_down(peer->check_index)) {
40+                continue;
41+            }
42+#endif
43+
44             if (peer->server.len != server->len
45                 || ngx_strncmp(peer->server.data, server->data, server->len)
46                    != 0)
47diff --git src/http/modules/ngx_http_upstream_ip_hash_module.c src/http/modules/ngx_http_upstream_ip_hash_module.c
48index 401b58e..ba656bd 100644
49--- src/http/modules/ngx_http_upstream_ip_hash_module.c
50+++ src/http/modules/ngx_http_upstream_ip_hash_module.c
51@@ -9,6 +9,9 @@
52 #include <ngx_core.h>
53 #include <ngx_http.h>
54
55+#if (NGX_HTTP_UPSTREAM_CHECK)
56+#include "ngx_http_upstream_check_module.h"
57+#endif
58
59 typedef struct {
60     /* the round robin data must be first */
61@@ -205,6 +208,15 @@ ngx_http_upstream_get_ip_hash_peer(ngx_peer_connection_t *pc, void *data)
62             goto next;
63         }
64
65+#if (NGX_HTTP_UPSTREAM_CHECK)
66+        ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
67+            "get ip_hash peer, check_index: %ui",
68+             peer->check_index);
69+        if (ngx_http_upstream_check_peer_down(peer->check_index)) {
70+            goto next;
71+        }
72+#endif
73+
74         if (peer->max_fails
75             && peer->fails >= peer->max_fails
76             && now - peer->checked <= peer->fail_timeout)
77diff --git src/http/modules/ngx_http_upstream_least_conn_module.c src/http/modules/ngx_http_upstream_least_conn_module.c
78index 92951bd..48aca2c 100644
79--- src/http/modules/ngx_http_upstream_least_conn_module.c
80+++ src/http/modules/ngx_http_upstream_least_conn_module.c
81@@ -9,6 +9,9 @@
82 #include <ngx_core.h>
83 #include <ngx_http.h>
84
85+#if (NGX_HTTP_UPSTREAM_CHECK)
86+#include "ngx_http_upstream_check_module.h"
87+#endif
88
89 static ngx_int_t ngx_http_upstream_init_least_conn_peer(ngx_http_request_t *r,
90     ngx_http_upstream_srv_conf_t *us);
91@@ -148,6 +151,16 @@ ngx_http_upstream_get_least_conn_peer(ngx_peer_connection_t *pc, void *data)
92             continue;
93         }
94
95+#if (NGX_HTTP_UPSTREAM_CHECK)
96+        ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
97+                "get least_conn peer, check_index: %ui",
98+                peer->check_index);
99+
100+        if (ngx_http_upstream_check_peer_down(peer->check_index)) {
101+            continue;
102+        }
103+#endif
104+
105         if (peer->max_fails
106             && peer->fails >= peer->max_fails
107             && now - peer->checked <= peer->fail_timeout)
108@@ -199,6 +212,16 @@ ngx_http_upstream_get_least_conn_peer(ngx_peer_connection_t *pc, void *data)
109                 continue;
110             }
111
112+#if (NGX_HTTP_UPSTREAM_CHECK)
113+            ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
114+                    "get least_conn peer, check_index: %ui",
115+                    peer->check_index);
116+
117+            if (ngx_http_upstream_check_peer_down(peer->check_index)) {
118+                continue;
119+            }
120+#endif
121+
122             if (peer->conns * best->weight != best->conns * peer->weight) {
123                 continue;
124             }
125diff --git src/http/ngx_http_upstream_round_robin.c src/http/ngx_http_upstream_round_robin.c
126index d6ae33b..416572a 100644
127--- src/http/ngx_http_upstream_round_robin.c
128+++ src/http/ngx_http_upstream_round_robin.c
129@@ -9,6 +9,9 @@
130 #include <ngx_core.h>
131 #include <ngx_http.h>
132
133+#if (NGX_HTTP_UPSTREAM_CHECK)
134+#include "ngx_http_upstream_check_module.h"
135+#endif
136
137 #define ngx_http_upstream_tries(p) ((p)->number                               \
138                                     + ((p)->next ? (p)->next->number : 0))
139@@ -96,7 +99,14 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
140                 peer[n].fail_timeout = server[i].fail_timeout;
141                 peer[n].down = server[i].down;
142                 peer[n].server = server[i].name;
143-
144+#if (NGX_HTTP_UPSTREAM_CHECK)
145+                if (!server[i].down) {
146+                    peer[n].check_index =
147+                        ngx_http_upstream_check_add_peer(cf, us, &server[i].addrs[j]);
148+                } else {
149+                    peer[n].check_index = (ngx_uint_t) NGX_ERROR;
150+                }
151+#endif
152                 *peerp = &peer[n];
153                 peerp = &peer[n].next;
154                 n++;
155@@ -159,7 +169,15 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
156                 peer[n].fail_timeout = server[i].fail_timeout;
157                 peer[n].down = server[i].down;
158                 peer[n].server = server[i].name;
159-
160+#if (NGX_HTTP_UPSTREAM_CHECK)
161+                if (!server[i].down) {
162+                    peer[n].check_index =
163+                        ngx_http_upstream_check_add_peer(cf, us, &server[i].addrs[j]);
164+                }
165+                else {
166+                    peer[n].check_index = (ngx_uint_t) NGX_ERROR;
167+                }
168+#endif
169                 *peerp = &peer[n];
170                 peerp = &peer[n].next;
171                 n++;
172@@ -225,6 +243,9 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
173         peer[i].current_weight = 0;
174         peer[i].max_fails = 1;
175         peer[i].fail_timeout = 10;
176+#if (NGX_HTTP_UPSTREAM_CHECK)
177+        peer[i].check_index = (ngx_uint_t) NGX_ERROR;
178+#endif
179         *peerp = &peer[i];
180         peerp = &peer[i].next;
181     }
182@@ -339,6 +360,9 @@ ngx_http_upstream_create_round_robin_peer(ngx_http_request_t *r,
183         peer[0].current_weight = 0;
184         peer[0].max_fails = 1;
185         peer[0].fail_timeout = 10;
186+#if (NGX_HTTP_UPSTREAM_CHECK)
187+        peer[0].check_index = (ngx_uint_t) NGX_ERROR;
188+#endif
189         peers->peer = peer;
190
191     } else {
192@@ -381,6 +405,9 @@ ngx_http_upstream_create_round_robin_peer(ngx_http_request_t *r,
193             peer[i].current_weight = 0;
194             peer[i].max_fails = 1;
195             peer[i].fail_timeout = 10;
196+#if (NGX_HTTP_UPSTREAM_CHECK)
197+            peer[i].check_index = (ngx_uint_t) NGX_ERROR;
198+#endif
199             *peerp = &peer[i];
200             peerp = &peer[i].next;
201         }
202@@ -441,6 +468,12 @@ ngx_http_upstream_get_round_robin_peer(ngx_peer_connection_t *pc, void *data)
203             goto failed;
204         }
205
206+#if (NGX_HTTP_UPSTREAM_CHECK)
207+        if (ngx_http_upstream_check_peer_down(peer->check_index)) {
208+            goto failed;
209+        }
210+#endif
211+
212         rrp->current = peer;
213
214     } else {
215@@ -542,6 +575,12 @@ ngx_http_upstream_get_peer(ngx_http_upstream_rr_peer_data_t *rrp)
216             continue;
217         }
218
219+#if (NGX_HTTP_UPSTREAM_CHECK)
220+        if (ngx_http_upstream_check_peer_down(peer->check_index)) {
221+            continue;
222+        }
223+#endif
224+
225         if (peer->max_fails
226             && peer->fails >= peer->max_fails
227             && now - peer->checked <= peer->fail_timeout)
228diff --git src/http/ngx_http_upstream_round_robin.h src/http/ngx_http_upstream_round_robin.h
229index f2c573f..75e0ed6 100644
230--- src/http/ngx_http_upstream_round_robin.h
231+++ src/http/ngx_http_upstream_round_robin.h
232@@ -35,6 +35,10 @@ struct ngx_http_upstream_rr_peer_s {
233     ngx_uint_t                      max_fails;
234     time_t                          fail_timeout;
235
236+#if (NGX_HTTP_UPSTREAM_CHECK)
237+    ngx_uint_t                      check_index;
238+#endif
239+
240     ngx_uint_t                      down;          /* unsigned  down:1; */
241
242 #if (NGX_HTTP_SSL)
243