From 8efe926dc5601397bc054aedf37594e9719a52f6 Mon Sep 17 00:00:00 2001 From: Igor Sysoev Date: Mon, 3 Mar 2008 20:04:06 +0000 Subject: [PATCH] fix r1903 --- src/http/modules/ngx_http_proxy_module.c | 1 + src/http/ngx_http_upstream.c | 3 ++- src/http/ngx_http_upstream.h | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/http/modules/ngx_http_proxy_module.c b/src/http/modules/ngx_http_proxy_module.c index d3f4c60ea..83eeac647 100644 --- a/src/http/modules/ngx_http_proxy_module.c +++ b/src/http/modules/ngx_http_proxy_module.c @@ -611,6 +611,7 @@ ngx_http_proxy_eval(ngx_http_request_t *r, ngx_http_proxy_ctx_t *ctx, r->upstream->resolved->host = u.host; r->upstream->resolved->port = (in_port_t) (u.no_port ? u.default_port: u.port); + r->upstream->resolved->default_port = u.default_port; return NGX_OK; } diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c index a46b819a4..241277902 100644 --- a/src/http/ngx_http_upstream.c +++ b/src/http/ngx_http_upstream.c @@ -392,7 +392,8 @@ ngx_http_upstream_init(ngx_http_request_t *r) uscf = uscfp[i]; if (uscf->host.len == host->len - && uscf->port == u->resolved->port + && ((uscf->port == 0 && u->resolved->default_port) + || uscf->port == u->resolved->port) && ngx_memcmp(uscf->host.data, host->data, host->len) == 0) { goto found; diff --git a/src/http/ngx_http_upstream.h b/src/http/ngx_http_upstream.h index 15615caec..2ed2797a2 100644 --- a/src/http/ngx_http_upstream.h +++ b/src/http/ngx_http_upstream.h @@ -201,6 +201,7 @@ typedef struct { typedef struct { ngx_str_t host; in_port_t port; + ngx_uint_t default_port; /* unsigned default_port:1 */ ngx_uint_t naddrs; in_addr_t *addrs; ngx_resolver_ctx_t *ctx;