diff options
Diffstat (limited to 'src/http/modules')
-rw-r--r-- | src/http/modules/ngx_http_charset_filter_module.c | 3 | ||||
-rw-r--r-- | src/http/modules/ngx_http_fastcgi_module.c | 28 | ||||
-rw-r--r-- | src/http/modules/ngx_http_proxy_module.c | 59 | ||||
-rw-r--r-- | src/http/modules/ngx_http_rewrite_module.c | 12 |
4 files changed, 40 insertions, 62 deletions
diff --git a/src/http/modules/ngx_http_charset_filter_module.c b/src/http/modules/ngx_http_charset_filter_module.c index 2ec138fb9..51f115b63 100644 --- a/src/http/modules/ngx_http_charset_filter_module.c +++ b/src/http/modules/ngx_http_charset_filter_module.c @@ -162,7 +162,8 @@ ngx_http_charset_header_filter(ngx_http_request_t *r) return ngx_http_next_header_filter(r); } - if (ngx_strstr(r->headers_out.content_type.data, "charset") != NULL) + if (r->main == r + && ngx_strstr(r->headers_out.content_type.data, "charset") != NULL) { return ngx_http_next_header_filter(r); } diff --git a/src/http/modules/ngx_http_fastcgi_module.c b/src/http/modules/ngx_http_fastcgi_module.c index 9b317f9d9..c5418070b 100644 --- a/src/http/modules/ngx_http_fastcgi_module.c +++ b/src/http/modules/ngx_http_fastcgi_module.c @@ -148,11 +148,6 @@ static ngx_str_t ngx_http_fastcgi_script_name = ngx_string("fastcgi_script_name"); -#if (NGX_PCRE) -static ngx_str_t ngx_http_fastcgi_uri = ngx_string("/"); -#endif - - static ngx_conf_post_t ngx_http_fastcgi_lowat_post = { ngx_http_fastcgi_lowat_check }; @@ -1448,7 +1443,6 @@ ngx_http_fastcgi_create_loc_conf(ngx_conf_t *cf) conf->upstream.max_temp_file_size_conf = NGX_CONF_UNSET_SIZE; conf->upstream.temp_file_write_size_conf = NGX_CONF_UNSET_SIZE; - conf->upstream.pass_unparsed_uri = NGX_CONF_UNSET; conf->upstream.method = NGX_CONF_UNSET_UINT; conf->upstream.pass_request_headers = NGX_CONF_UNSET; conf->upstream.pass_request_body = NGX_CONF_UNSET; @@ -1602,16 +1596,6 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) NGX_HTTP_FASTCGI_TEMP_PATH, 1, 2, 0, ngx_garbage_collector_temp_handler, cf); - ngx_conf_merge_value(conf->upstream.pass_unparsed_uri, - prev->upstream.pass_unparsed_uri, 0); - - if (conf->upstream.pass_unparsed_uri && conf->upstream.location->len > 1) { - ngx_log_error(NGX_LOG_EMERG, cf->log, 0, - "\"fastcgi_pass_unparsed_uri\" can be set for " - "location \"/\" or given by regular expression."); - return NGX_CONF_ERROR; - } - if (conf->upstream.method == NGX_CONF_UNSET_UINT) { conf->upstream.method = prev->upstream.method; } @@ -1812,6 +1796,10 @@ ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) ngx_unix_domain_upstream_t unix_upstream; #endif + if (lcf->upstream.schema.len) { + return "is duplicate"; + } + value = cf->args->elts; if (ngx_strncasecmp(value[1].data, "unix:", 5) == 0) { @@ -1828,6 +1816,8 @@ ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) return NGX_CONF_ERROR; } + lcf->peers->peer[0].uri_separator = ""; + #else ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "the unix domain sockets are not supported " @@ -1850,18 +1840,12 @@ ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) lcf->upstream.schema.len = sizeof("fastcgi://") - 1; lcf->upstream.schema.data = (u_char *) "fastcgi://"; - lcf->upstream.uri.len = sizeof("/") - 1; - lcf->upstream.uri.data = (u_char *) "/"; clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module); clcf->handler = ngx_http_fastcgi_handler; -#if (NGX_PCRE) - lcf->upstream.location = clcf->regex ? &ngx_http_fastcgi_uri : &clcf->name; -#else lcf->upstream.location = &clcf->name; -#endif if (clcf->name.data[clcf->name.len - 1] == '/') { clcf->auto_redirect = 1; diff --git a/src/http/modules/ngx_http_proxy_module.c b/src/http/modules/ngx_http_proxy_module.c index fd41017d3..e1ee7b4e9 100644 --- a/src/http/modules/ngx_http_proxy_module.c +++ b/src/http/modules/ngx_http_proxy_module.c @@ -159,13 +159,6 @@ static ngx_command_t ngx_http_proxy_commands[] = { offsetof(ngx_http_proxy_loc_conf_t, upstream.redirect_errors), NULL }, - { ngx_string("proxy_pass_unparsed_uri"), - NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, - ngx_conf_set_flag_slot, - NGX_HTTP_LOC_CONF_OFFSET, - offsetof(ngx_http_proxy_loc_conf_t, upstream.pass_unparsed_uri), - NULL }, - { ngx_string("proxy_set_header"), NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2, ngx_conf_set_table_elt_slot, @@ -342,11 +335,6 @@ static ngx_http_variable_t ngx_http_proxy_vars[] = { }; -#if (NGX_PCRE) -static ngx_str_t ngx_http_proxy_uri = ngx_string("/"); -#endif - - static ngx_int_t ngx_http_proxy_handler(ngx_http_request_t *r) { @@ -432,7 +420,7 @@ ngx_http_proxy_create_request(ngx_http_request_t *r) loc_len = r->valid_location ? u->conf->location->len : 0; - if (plcf->upstream.pass_unparsed_uri && r->valid_unparsed_uri) { + if (u->conf->uri.len == 0 && r->valid_unparsed_uri) { len += r->unparsed_uri.len; } else { @@ -514,11 +502,15 @@ ngx_http_proxy_create_request(ngx_http_request_t *r) r->method_name.len + 1); } - if (plcf->upstream.pass_unparsed_uri && r->valid_unparsed_uri) { + u->uri.data = b->last; + + if (u->conf->uri.len == 0 && r->valid_unparsed_uri) { b->last = ngx_cpymem(b->last, r->unparsed_uri.data, r->unparsed_uri.len); } else { - b->last = ngx_cpymem(b->last, u->conf->uri.data, u->conf->uri.len); + if (r->valid_location) { + b->last = ngx_cpymem(b->last, u->conf->uri.data, u->conf->uri.len); + } if (escape) { ngx_escape_uri(b->last, r->uri.data + loc_len, @@ -536,6 +528,8 @@ ngx_http_proxy_create_request(ngx_http_request_t *r) } } + u->uri.len = b->last - u->uri.data; + b->last = ngx_cpymem(b->last, ngx_http_proxy_version, sizeof(ngx_http_proxy_version) - 1); @@ -1312,7 +1306,6 @@ ngx_http_proxy_create_loc_conf(ngx_conf_t *cf) conf->upstream.max_temp_file_size_conf = NGX_CONF_UNSET_SIZE; conf->upstream.temp_file_write_size_conf = NGX_CONF_UNSET_SIZE; - conf->upstream.pass_unparsed_uri = NGX_CONF_UNSET; conf->upstream.method = NGX_CONF_UNSET_UINT; conf->upstream.pass_request_headers = NGX_CONF_UNSET; conf->upstream.pass_request_body = NGX_CONF_UNSET; @@ -1467,16 +1460,6 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) NGX_HTTP_PROXY_TEMP_PATH, 1, 2, 0, ngx_garbage_collector_temp_handler, cf); - ngx_conf_merge_value(conf->upstream.pass_unparsed_uri, - prev->upstream.pass_unparsed_uri, 0); - - if (conf->upstream.pass_unparsed_uri && conf->upstream.location->len > 1) { - ngx_log_error(NGX_LOG_EMERG, cf->log, 0, - "\"proxy_pass_unparsed_uri\" can be set for " - "location \"/\" or given by regular expression."); - return NGX_CONF_ERROR; - } - if (conf->upstream.method == NGX_CONF_UNSET_UINT) { conf->upstream.method = prev->upstream.method; } @@ -1759,7 +1742,6 @@ ngx_http_proxy_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_http_proxy_loc_conf_t *plcf = conf; - ngx_uint_t i; ngx_str_t *value, *url; ngx_inet_upstream_t inet_upstream; ngx_http_core_loc_conf_t *clcf; @@ -1767,6 +1749,10 @@ ngx_http_proxy_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) ngx_unix_domain_upstream_t unix_upstream; #endif + if (plcf->upstream.schema.len) { + return "is duplicate"; + } + value = cf->args->elts; url = &value[1]; @@ -1792,8 +1778,6 @@ ngx_http_proxy_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) return NGX_CONF_ERROR; } - plcf->peers->peer[0].uri_separator = ":"; - plcf->host_header.len = sizeof("localhost") - 1; plcf->host_header.data = (u_char *) "localhost"; plcf->upstream.uri = unix_upstream.uri; @@ -1820,10 +1804,6 @@ ngx_http_proxy_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) return NGX_CONF_ERROR; } - for (i = 0; i < plcf->peers->number; i++) { - plcf->peers->peer[i].uri_separator = ""; - } - plcf->host_header = inet_upstream.host_header; plcf->port_text = inet_upstream.port_text; plcf->upstream.uri = inet_upstream.uri; @@ -1836,10 +1816,17 @@ ngx_http_proxy_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) clcf->handler = ngx_http_proxy_handler; -#if (NGX_PCRE) - plcf->upstream.location = clcf->regex ? &ngx_http_proxy_uri : &clcf->name; -#else plcf->upstream.location = &clcf->name; + +#if (NGX_PCRE) + + if (clcf->regex && plcf->upstream.uri.len) { + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, + "\"proxy_pass\" may not have URI part in " + "location given by regular expression"); + return NGX_CONF_ERROR; + } + #endif plcf->upstream.url = *url; diff --git a/src/http/modules/ngx_http_rewrite_module.c b/src/http/modules/ngx_http_rewrite_module.c index 693495e3b..c575d4343 100644 --- a/src/http/modules/ngx_http_rewrite_module.c +++ b/src/http/modules/ngx_http_rewrite_module.c @@ -691,7 +691,7 @@ ngx_http_rewrite_if(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) if (pclcf->locations.elts == NULL) { if (ngx_array_init(&pclcf->locations, cf->pool, 4, sizeof(void *)) - == NGX_ERROR) + == NGX_ERROR) { return NGX_CONF_ERROR; } @@ -759,6 +759,10 @@ ngx_http_rewrite_if(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) if_code->next = (u_char *) lcf->codes->elts + lcf->codes->nelts - (u_char *) if_code; + /* the code array belong to parent block */ + + nlcf->codes = NULL; + return NGX_CONF_OK; } @@ -1048,8 +1052,10 @@ ngx_http_rewrite_set(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) return NGX_CONF_ERROR; } - v->handler = ngx_http_rewrite_var; - v->data = index; + if (v->handler == NULL) { + v->handler = ngx_http_rewrite_var; + v->data = index; + } n = ngx_http_script_variables_count(&value[2]); |