}
u->no_port = 1;
-
- if (!u->no_resolve) {
- u->port = u->default_port;
- sin->sin_port = htons(u->default_port);
- }
+ u->port = u->default_port;
+ sin->sin_port = htons(u->default_port);
}
len = last - host;
} else {
u->no_port = 1;
-
- if (!u->no_resolve) {
- u->port = u->default_port;
- sin6->sin6_port = htons(u->default_port);
- }
+ u->port = u->default_port;
+ sin6->sin6_port = htons(u->default_port);
}
}
value = cf->args->elts;
u.host = value[1];
u.no_resolve = 1;
+ u.no_port = 1;
uscf = ngx_http_upstream_add(cf, &u, NGX_HTTP_UPSTREAM_CREATE
|NGX_HTTP_UPSTREAM_WEIGHT
return NULL;
}
- if ((uscfp[i]->flags & NGX_HTTP_UPSTREAM_CREATE) && u->port) {
+ if ((uscfp[i]->flags & NGX_HTTP_UPSTREAM_CREATE) && !u->no_port) {
ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
"upstream \"%V\" may not have port %d",
&u->host, u->port);
return NULL;
}
- if ((flags & NGX_HTTP_UPSTREAM_CREATE) && uscfp[i]->port) {
+ if ((flags & NGX_HTTP_UPSTREAM_CREATE) && !uscfp[i]->no_port) {
ngx_log_error(NGX_LOG_WARN, cf->log, 0,
"upstream \"%V\" may not have port %d in %s:%ui",
&u->host, uscfp[i]->port,
return NULL;
}
- if (uscfp[i]->port != u->port) {
+ if (uscfp[i]->port && u->port
+ && uscfp[i]->port != u->port)
+ {
continue;
}
uscf->line = cf->conf_file->line;
uscf->port = u->port;
uscf->default_port = u->default_port;
+ uscf->no_port = u->no_port;
if (u->naddrs == 1) {
uscf->servers = ngx_array_create(cf->pool, 1,
/* an upstream implicitly defined by proxy_pass, etc. */
- if (us->port == 0 && us->default_port == 0) {
+ if (us->port == 0) {
ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
"no port in upstream \"%V\" in %s:%ui",
&us->host, us->file_name, us->line);
ngx_memzero(&u, sizeof(ngx_url_t));
u.host = us->host;
- u.port = (in_port_t) (us->port ? us->port : us->default_port);
+ u.port = us->port;
if (ngx_inet_resolve_host(cf->pool, &u) != NGX_OK) {
if (u.err) {