summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2010-02-01 14:01:24 +0000
committerIgor Sysoev <igor@sysoev.ru>2010-02-01 14:01:24 +0000
commit393300584e0fcd36356da7b7198e3f43afd97240 (patch)
tree1e1ddfb66016aca7b9b2f0ea7f98fc52cb694d56
parentab00f267591c88b2c46d2e3c1e9dfd8f92765c6a (diff)
downloadnginx-393300584e0fcd36356da7b7198e3f43afd97240.tar.gz
nginx-393300584e0fcd36356da7b7198e3f43afd97240.tar.bz2
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
Diffstat (limited to '')
-rw-r--r--auto/install4
-rw-r--r--conf/fastcgi.conf24
-rw-r--r--src/http/modules/ngx_http_fastcgi_module.c9
-rw-r--r--src/http/modules/ngx_http_proxy_module.c37
-rw-r--r--src/http/ngx_http_upstream.c2
5 files changed, 55 insertions, 21 deletions
diff --git a/auto/install b/auto/install
index f876891f8..815fcb335 100644
--- a/auto/install
+++ b/auto/install
@@ -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'
diff --git a/conf/fastcgi.conf b/conf/fastcgi.conf
new file mode 100644
index 000000000..fab09eb24
--- /dev/null
+++ b/conf/fastcgi.conf
@@ -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;
diff --git a/src/http/modules/ngx_http_fastcgi_module.c b/src/http/modules/ngx_http_fastcgi_module.c
index 3ce608db1..bdc52b644 100644
--- a/src/http/modules/ngx_http_fastcgi_module.c
+++ b/src/http/modules/ngx_http_fastcgi_module.c
@@ -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;
}
diff --git a/src/http/modules/ngx_http_proxy_module.c b/src/http/modules/ngx_http_proxy_module.c
index f4ed8a7a1..9da8b4c55 100644
--- a/src/http/modules/ngx_http_proxy_module.c
+++ b/src/http/modules/ngx_http_proxy_module.c
@@ -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);
- *p++ = '/';
- ngx_memcpy(p, url.uri.data, url.uri.len);
+ url.uri.len++;
+ url.uri.data = p - 1;
+ }
- 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;
}
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
index ed86a382c..943ef69e8 100644
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -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) {