mirror of
https://github.com/nginx/nginx.git
synced 2024-11-27 23:49:00 +08:00
fix case proxy_pass URL is evaluted to http://host?args
This commit is contained in:
parent
c239da5055
commit
164abfb26f
@ -251,7 +251,7 @@ ngx_parse_unix_domain_url(ngx_pool_t *pool, ngx_url_t *u)
|
||||
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 @@ ngx_parse_inet_url(ngx_pool_t *pool, ngx_url_t *u)
|
||||
|
||||
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";
|
||||
|
@ -536,10 +536,11 @@ static ngx_int_t
|
||||
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 @@ ngx_http_proxy_eval(ngx_http_request_t *r, ngx_http_proxy_ctx_t *ctx,
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user