Mercurial > hg > nginx
changeset 3425:0189a8f4c7c3 stable-0.7
merge r2990, r3324, r3384, r3419:
various proxy/FastCGI fixes:
*) do auto redirect for proxy_pass/fastcgi_pass with variables
*) allow "proxy_pass http://$backend" without URI part
*) add conf/fastcgi.conf
*) delete u->cleanup mark, this fixes large values in $upstream_response_time,
the bug had been introduced in r3246
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 01 Feb 2010 14:01:24 +0000 |
parents | c6ecb3fe577b |
children | eef19bd3c51e |
files | auto/install conf/fastcgi.conf src/http/modules/ngx_http_fastcgi_module.c src/http/modules/ngx_http_proxy_module.c src/http/ngx_http_upstream.c |
diffstat | 5 files changed, 55 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/auto/install Mon Feb 01 13:53:14 2010 +0000 +++ b/auto/install Mon Feb 01 14:01:24 2010 +0000 @@ -101,6 +101,10 @@ cp conf/fastcgi_params \ '\$(DESTDIR)$NGX_CONF_PREFIX/fastcgi_params.default' + test -f '\$(DESTDIR)$NGX_CONF_PREFIX/fastcgi.conf' \ + || cp conf/fastcgi.conf '\$(DESTDIR)$NGX_CONF_PREFIX' + cp conf/fastcgi.conf '\$(DESTDIR)$NGX_CONF_PREFIX/fastcgi.conf.default' + test -f '\$(DESTDIR)$NGX_CONF_PATH' \ || cp conf/nginx.conf '\$(DESTDIR)$NGX_CONF_PATH' cp conf/nginx.conf '\$(DESTDIR)$NGX_CONF_PREFIX/nginx.conf.default'
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/conf/fastcgi.conf Mon Feb 01 14:01:24 2010 +0000 @@ -0,0 +1,24 @@ + +fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; +fastcgi_param QUERY_STRING $query_string; +fastcgi_param REQUEST_METHOD $request_method; +fastcgi_param CONTENT_TYPE $content_type; +fastcgi_param CONTENT_LENGTH $content_length; + +fastcgi_param SCRIPT_NAME $fastcgi_script_name; +fastcgi_param REQUEST_URI $request_uri; +fastcgi_param DOCUMENT_URI $document_uri; +fastcgi_param DOCUMENT_ROOT $document_root; +fastcgi_param SERVER_PROTOCOL $server_protocol; + +fastcgi_param GATEWAY_INTERFACE CGI/1.1; +fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; + +fastcgi_param REMOTE_ADDR $remote_addr; +fastcgi_param REMOTE_PORT $remote_port; +fastcgi_param SERVER_ADDR $server_addr; +fastcgi_param SERVER_PORT $server_port; +fastcgi_param SERVER_NAME $server_name; + +# PHP only, required if PHP was built with --enable-force-cgi-redirect +fastcgi_param REDIRECT_STATUS 200;
--- a/src/http/modules/ngx_http_fastcgi_module.c Mon Feb 01 13:53:14 2010 +0000 +++ b/src/http/modules/ngx_http_fastcgi_module.c Mon Feb 01 14:01:24 2010 +0000 @@ -2433,8 +2433,13 @@ } clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module); + clcf->handler = ngx_http_fastcgi_handler; + if (clcf->name.data[clcf->name.len - 1] == '/') { + clcf->auto_redirect = 1; + } + value = cf->args->elts; url = &value[1]; @@ -2470,10 +2475,6 @@ return NGX_CONF_ERROR; } - if (clcf->name.data[clcf->name.len - 1] == '/') { - clcf->auto_redirect = 1; - } - return NGX_CONF_OK; }
--- a/src/http/modules/ngx_http_proxy_module.c Mon Feb 01 13:53:14 2010 +0000 +++ b/src/http/modules/ngx_http_proxy_module.c Mon Feb 01 14:01:24 2010 +0000 @@ -717,17 +717,22 @@ return NGX_ERROR; } - if (url.uri.len && url.uri.data[0] == '?') { - p = ngx_pnalloc(r->pool, url.uri.len + 1); - if (p == NULL) { - return NGX_ERROR; + if (url.uri.len) { + if (url.uri.data[0] == '?') { + p = ngx_pnalloc(r->pool, url.uri.len + 1); + if (p == NULL) { + return NGX_ERROR; + } + + *p++ = '/'; + ngx_memcpy(p, url.uri.data, url.uri.len); + + url.uri.len++; + url.uri.data = p - 1; } - *p++ = '/'; - ngx_memcpy(p, url.uri.data, url.uri.len); - - url.uri.len++; - url.uri.data = p - 1; + } else { + url.uri = r->unparsed_uri; } ctx->vars.key_start = u->schema; @@ -2585,6 +2590,12 @@ clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module); + clcf->handler = ngx_http_proxy_handler; + + if (clcf->name.data[clcf->name.len - 1] == '/') { + clcf->auto_redirect = 1; + } + value = cf->args->elts; url = &value[1]; @@ -2613,8 +2624,6 @@ } #endif - clcf->handler = ngx_http_proxy_handler; - return NGX_CONF_OK; } @@ -2661,8 +2670,6 @@ ngx_http_proxy_set_vars(&u, &plcf->vars); - clcf->handler = ngx_http_proxy_handler; - plcf->location = clcf->name; if (clcf->named @@ -2686,10 +2693,6 @@ plcf->url = *url; - if (clcf->name.data[clcf->name.len - 1] == '/') { - clcf->auto_redirect = 1; - } - return NGX_CONF_OK; }
--- a/src/http/ngx_http_upstream.c Mon Feb 01 13:53:14 2010 +0000 +++ b/src/http/ngx_http_upstream.c Mon Feb 01 14:01:24 2010 +0000 @@ -364,6 +364,7 @@ if (u && u->cleanup) { ngx_http_upstream_cleanup(r); *u->cleanup = NULL; + u->cleanup = NULL; } u = ngx_pcalloc(r->pool, sizeof(ngx_http_upstream_t)); @@ -2834,6 +2835,7 @@ if (u->cleanup) { *u->cleanup = NULL; + u->cleanup = NULL; } if (u->state && u->state->response_sec) {