Mercurial > hg > nginx
changeset 2284:c3035feb6638
fix case proxy_pass URL is evaluted to http://host?args
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 24 Oct 2008 19:34:24 +0000 |
parents | 231b52f8adc0 |
children | c77f4710595c |
files | src/core/ngx_inet.c src/http/modules/ngx_http_proxy_module.c |
diffstat | 2 files changed, 30 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/core/ngx_inet.c Fri Oct 24 15:12:11 2008 +0000 +++ b/src/core/ngx_inet.c Fri Oct 24 19:34:24 2008 +0000 @@ -251,7 +251,7 @@ static ngx_int_t ngx_parse_inet_url(ngx_pool_t *pool, ngx_url_t *u) { - u_char *p, *host, *port, *last, *uri; + u_char *p, *host, *port, *last, *uri, *args; size_t len; ngx_int_t n; struct hostent *h; @@ -266,6 +266,17 @@ uri = ngx_strlchr(host, last, '/'); + args = ngx_strlchr(host, last, '?'); + + if (args) { + if (uri == NULL) { + uri = args; + + } else if (args < uri) { + uri = args; + } + } + if (uri) { if (u->listen || !u->uri_part) { u->err = "invalid host";
--- a/src/http/modules/ngx_http_proxy_module.c Fri Oct 24 15:12:11 2008 +0000 +++ b/src/http/modules/ngx_http_proxy_module.c Fri Oct 24 19:34:24 2008 +0000 @@ -536,10 +536,11 @@ ngx_http_proxy_eval(ngx_http_request_t *r, ngx_http_proxy_ctx_t *ctx, ngx_http_proxy_loc_conf_t *plcf) { - size_t add; - u_short port; - ngx_str_t proxy; - ngx_url_t u; + u_char *p; + size_t add; + u_short port; + ngx_str_t proxy; + ngx_url_t u; if (ngx_http_script_run(r, &proxy, plcf->proxy_lengths->elts, 0, plcf->proxy_values->elts) @@ -589,6 +590,19 @@ return NGX_ERROR; } + if (u.uri.len && u.uri.data[0] == '?') { + p = ngx_pnalloc(r->pool, u.uri.len + 1); + if (p == NULL) { + return NGX_ERROR; + } + + *p++ = '/'; + ngx_memcpy(p, u.uri.data, u.uri.len); + + u.uri.len++; + u.uri.data = p - 1; + } + if (ngx_http_proxy_set_vars(r->pool, &u, &ctx->vars) != NGX_OK) { return NGX_ERROR; }