mirror of
https://github.com/nginx/nginx.git
synced 2024-11-23 20:19:02 +08:00
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
This commit is contained in:
parent
ab00f26759
commit
393300584e
@ -101,6 +101,10 @@ install: $NGX_OBJS${ngx_dirsep}nginx${ngx_binext} \
|
||||
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'
|
||||
|
24
conf/fastcgi.conf
Normal file
24
conf/fastcgi.conf
Normal file
@ -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;
|
@ -2433,8 +2433,13 @@ ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
}
|
||||
|
||||
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 @@ ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
if (clcf->name.data[clcf->name.len - 1] == '/') {
|
||||
clcf->auto_redirect = 1;
|
||||
}
|
||||
|
||||
return NGX_CONF_OK;
|
||||
}
|
||||
|
||||
|
@ -717,17 +717,22 @@ ngx_http_proxy_eval(ngx_http_request_t *r, ngx_http_proxy_ctx_t *ctx,
|
||||
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 @@ ngx_http_proxy_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
|
||||
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 @@ ngx_http_proxy_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
}
|
||||
#endif
|
||||
|
||||
clcf->handler = ngx_http_proxy_handler;
|
||||
|
||||
return NGX_CONF_OK;
|
||||
}
|
||||
|
||||
@ -2661,8 +2670,6 @@ ngx_http_proxy_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
|
||||
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 @@ ngx_http_proxy_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
|
||||
plcf->url = *url;
|
||||
|
||||
if (clcf->name.data[clcf->name.len - 1] == '/') {
|
||||
clcf->auto_redirect = 1;
|
||||
}
|
||||
|
||||
return NGX_CONF_OK;
|
||||
}
|
||||
|
||||
|
@ -364,6 +364,7 @@ ngx_http_upstream_create(ngx_http_request_t *r)
|
||||
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 @@ ngx_http_upstream_finalize_request(ngx_http_request_t *r,
|
||||
|
||||
if (u->cleanup) {
|
||||
*u->cleanup = NULL;
|
||||
u->cleanup = NULL;
|
||||
}
|
||||
|
||||
if (u->state && u->state->response_sec) {
|
||||
|
Loading…
Reference in New Issue
Block a user