diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c index a923c0e..e66ba32 100644 --- a/src/http/ngx_http_upstream.c +++ b/src/http/ngx_http_upstream.c @@ -6958,6 +6958,10 @@ ngx_http_upstream_init_process(ngx_cycle_t *cycle) uscfp = umcf->upstreams.elts; for (i = 0; i < umcf->upstreams.nelts; i++) { + if (!(uscfp[i]->flags & T_NGX_HTTP_UPSTREAM_RANDOM_FLAG)) { + continue; + } + peers = uscfp[i]->peer.data; if (peers == NULL) { diff --git a/src/http/ngx_http_upstream.h b/src/http/ngx_http_upstream.h index deff13a..e671c7a 100644 --- a/src/http/ngx_http_upstream.h +++ b/src/http/ngx_http_upstream.h @@ -133,6 +133,9 @@ typedef struct { #define NGX_HTTP_UPSTREAM_BACKUP 0x0020 #define NGX_HTTP_UPSTREAM_MAX_CONNS 0x0100 #define NGX_HTTP_UPSTREAM_ID 0x0040 +#if (T_NGX_HTTP_UPSTREAM_RANDOM) +#define T_NGX_HTTP_UPSTREAM_RANDOM_FLAG 0x0200 +#endif struct ngx_http_upstream_srv_conf_s { diff --git a/src/http/ngx_http_upstream_round_robin.c b/src/http/ngx_http_upstream_round_robin.c index 51e5a51..938706c 100644 --- a/src/http/ngx_http_upstream_round_robin.c +++ b/src/http/ngx_http_upstream_round_robin.c @@ -41,6 +41,9 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf, ngx_http_upstream_rr_peers_t *peers, *backup; us->peer.init = ngx_http_upstream_init_round_robin_peer; +#if (T_NGX_HTTP_UPSTREAM_RANDOM) + us->flags = T_NGX_HTTP_UPSTREAM_RANDOM_FLAG; +#endif if (us->servers) { server = us->servers->elts;