diff options
author | Igor Sysoev <igor@sysoev.ru> | 2005-07-14 12:48:44 +0000 |
---|---|---|
committer | Jonathan Kolb <jon@b0g.us> | 2005-07-14 12:48:44 +0000 |
commit | dc01b38f28585575807f780b9c147729cf93000a (patch) | |
tree | 0abdbdefc18a30def9a1393ab6906fcc74a77eff /src/http/modules | |
parent | 4b06bf9c8c9f12978b3c2c1aa1b363c519f3a03e (diff) | |
download | nginx-dc01b38f28585575807f780b9c147729cf93000a.tar.gz |
Changes with nginx 0.1.39 14 Jul 2005v0.1.39
*) The changes in the ngx_http_charset_module: the "default_charset"
directive is canceled; the "charset" directive sets the response
charset; the "source_charset" directive sets the source charset only.
*) Bugfix: the backend "WWW-Authenticate" header line did not
transferred while the 401 response code redirecting.
*) Bugfix: the ngx_http_proxy_module and ngx_http_fastcgi_module may
close a connection before anything was transferred to a client; bug
appeared in 0.1.38.
*) Workaround: the Linux glibc crypt_r() initialization bug.
*) Bugfix: the ngx_http_ssi_module did not support the relative URI in
the "include virtual" command.
*) Bugfix: if the backend response had the "Location" header line and
nginx should not rewrite this line, then the 500 code response body
was transferred; bug appeared in 0.1.29.
*) Bugfix: some directives of the ngx_http_proxy_module and
ngx_http_fastcgi_module were not inherited from the server to the
location level; bug appeared in 0.1.29.
*) Bugfix: the ngx_http_ssl_module did not support the certificate
chain.
*) Bugfix: the ngx_http_autoindex_module did not show correctly the
long file names; bug appeared in 0.1.38.
*) Bugfixes in IMAP/POP3 proxy in interaction with a backend at the
login state.
Diffstat (limited to 'src/http/modules')
-rw-r--r-- | src/http/modules/ngx_http_autoindex_module.c | 14 | ||||
-rw-r--r-- | src/http/modules/ngx_http_charset_filter_module.c | 252 | ||||
-rw-r--r-- | src/http/modules/ngx_http_fastcgi_module.c | 76 | ||||
-rw-r--r-- | src/http/modules/ngx_http_gzip_filter_module.c | 2 | ||||
-rw-r--r-- | src/http/modules/ngx_http_proxy_module.c | 92 | ||||
-rw-r--r-- | src/http/modules/ngx_http_ssi_filter_module.c | 52 | ||||
-rw-r--r-- | src/http/modules/ngx_http_ssl_module.c | 11 |
7 files changed, 287 insertions, 212 deletions
diff --git a/src/http/modules/ngx_http_autoindex_module.c b/src/http/modules/ngx_http_autoindex_module.c index d12834083..a7246b04d 100644 --- a/src/http/modules/ngx_http_autoindex_module.c +++ b/src/http/modules/ngx_http_autoindex_module.c @@ -315,16 +315,16 @@ ngx_http_autoindex_handler(ngx_http_request_t *r) entry->name.len = len; - entry->escape = 2 * ngx_escape_uri(NULL, ngx_de_name(&dir), len, - NGX_ESCAPE_HTML); - - entry->name.data = ngx_palloc(pool, len + entry->escape + 1); + entry->name.data = ngx_palloc(pool, len + 1); if (entry->name.data == NULL) { return ngx_http_autoindex_error(r, &dir, dname.data); } ngx_cpystrn(entry->name.data, ngx_de_name(&dir), len + 1); + entry->escape = 2 * ngx_escape_uri(NULL, ngx_de_name(&dir), len, + NGX_ESCAPE_HTML); + if (r->utf8) { entry->utf_len = ngx_utf_length(&entry->name); } else { @@ -353,14 +353,14 @@ ngx_http_autoindex_handler(ngx_http_request_t *r) entry = entries.elts; for (i = 0; i < entries.nelts; i++) { len += sizeof("<a href=\"") - 1 - + 1 /* 1 is for "/" */ + entry[i].name.len + entry[i].escape + + 1 /* 1 is for "/" */ + sizeof("\">") - 1 + entry[i].name.len - entry[i].utf_len + NGX_HTTP_AUTOINDEX_NAME_LEN + sizeof(">") - 2 + sizeof("</a>") - 1 + sizeof(" 28-Sep-1970 12:00 ") - 1 - + 20 + + 20 /* the file size */ + 2; } @@ -407,7 +407,7 @@ ngx_http_autoindex_handler(ngx_http_request_t *r) len = entry[i].utf_len; - if (len) { + if (entry[i].name.len - len) { if (len > NGX_HTTP_AUTOINDEX_NAME_LEN) { copy = NGX_HTTP_AUTOINDEX_NAME_LEN - 3 + 1; diff --git a/src/http/modules/ngx_http_charset_filter_module.c b/src/http/modules/ngx_http_charset_filter_module.c index caf3f3f70..62c81e116 100644 --- a/src/http/modules/ngx_http_charset_filter_module.c +++ b/src/http/modules/ngx_http_charset_filter_module.c @@ -9,18 +9,26 @@ #include <ngx_http.h> +#define NGX_HTTP_NO_CHARSET -2 + + typedef struct { char **tables; ngx_str_t name; - unsigned server:1; - unsigned utf8:1; + ngx_uint_t utf8; /* unsigned utf8:1; */ } ngx_http_charset_t; typedef struct { ngx_int_t src; ngx_int_t dst; +} ngx_http_charset_recode_t; + + +typedef struct { + ngx_int_t src; + ngx_int_t dst; char *src2dst; char *dst2src; } ngx_http_charset_tables_t; @@ -29,13 +37,12 @@ typedef struct { typedef struct { ngx_array_t charsets; /* ngx_http_charset_t */ ngx_array_t tables; /* ngx_http_charset_tables_t */ + ngx_array_t recodes; /* ngx_http_charset_recode_t */ } ngx_http_charset_main_conf_t; typedef struct { - ngx_flag_t enable; - - ngx_int_t default_charset; + ngx_int_t charset; ngx_int_t source_charset; } ngx_http_charset_loc_conf_t; @@ -46,7 +53,7 @@ typedef struct { } ngx_http_charset_ctx_t; -static ngx_uint_t ngx_charset_recode(ngx_buf_t *b, char *table); +static ngx_uint_t ngx_http_charset_recode(ngx_buf_t *b, char *table); static char *ngx_charset_map_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); @@ -59,40 +66,35 @@ static ngx_int_t ngx_http_add_charset(ngx_array_t *charsets, ngx_str_t *name); static ngx_int_t ngx_http_charset_filter_init(ngx_cycle_t *cycle); static void *ngx_http_charset_create_main_conf(ngx_conf_t *cf); -static char *ngx_http_charset_init_main_conf(ngx_conf_t *cf, void *conf); static void *ngx_http_charset_create_loc_conf(ngx_conf_t *cf); static char *ngx_http_charset_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child); +static ngx_int_t ngx_http_charset_postconfiguration(ngx_conf_t *cf); static ngx_command_t ngx_http_charset_filter_commands[] = { - { ngx_string("charset_map"), - NGX_HTTP_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_TAKE2, - ngx_charset_map_block, - NGX_HTTP_MAIN_CONF_OFFSET, - 0, - NULL }, - - { ngx_string("default_charset"), - NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, + { ngx_string("charset"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_SIF_CONF + |NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF|NGX_CONF_TAKE1, ngx_http_set_charset_slot, NGX_HTTP_LOC_CONF_OFFSET, - offsetof(ngx_http_charset_loc_conf_t, default_charset), + offsetof(ngx_http_charset_loc_conf_t, charset), NULL }, { ngx_string("source_charset"), - NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_SIF_CONF + |NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF|NGX_CONF_TAKE1, ngx_http_set_charset_slot, NGX_HTTP_LOC_CONF_OFFSET, offsetof(ngx_http_charset_loc_conf_t, source_charset), NULL }, - { ngx_string("charset"), - NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, - ngx_conf_set_flag_slot, - NGX_HTTP_LOC_CONF_OFFSET, - offsetof(ngx_http_charset_loc_conf_t, enable), + { ngx_string("charset_map"), + NGX_HTTP_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_TAKE2, + ngx_charset_map_block, + NGX_HTTP_MAIN_CONF_OFFSET, + 0, NULL }, ngx_null_command @@ -101,10 +103,10 @@ static ngx_command_t ngx_http_charset_filter_commands[] = { static ngx_http_module_t ngx_http_charset_filter_module_ctx = { NULL, /* preconfiguration */ - NULL, /* postconfiguration */ + ngx_http_charset_postconfiguration, /* postconfiguration */ ngx_http_charset_create_main_conf, /* create main configuration */ - ngx_http_charset_init_main_conf, /* init main configuration */ + NULL, /* init main configuration */ NULL, /* create server configuration */ NULL, /* merge server configuration */ @@ -139,7 +141,7 @@ ngx_http_charset_header_filter(ngx_http_request_t *r) mcf = ngx_http_get_module_main_conf(r, ngx_http_charset_filter_module); lcf = ngx_http_get_module_loc_conf(r, ngx_http_charset_filter_module); - if (lcf->enable == 0) { + if (lcf->charset == NGX_HTTP_NO_CHARSET) { return ngx_http_next_header_filter(r); } @@ -176,10 +178,12 @@ ngx_http_charset_header_filter(ngx_http_request_t *r) } charsets = mcf->charsets.elts; - r->headers_out.charset = charsets[lcf->default_charset].name; - r->utf8 = charsets[lcf->default_charset].utf8; + r->headers_out.charset = charsets[lcf->charset].name; + r->utf8 = charsets[lcf->charset].utf8; - if (lcf->default_charset == lcf->source_charset) { + if (lcf->source_charset == NGX_CONF_UNSET + || lcf->source_charset == lcf->charset) + { return ngx_http_next_header_filter(r); } @@ -218,10 +222,10 @@ ngx_http_charset_body_filter(ngx_http_request_t *r, ngx_chain_t *in) lcf = ngx_http_get_module_loc_conf(r, ngx_http_charset_filter_module); charsets = mcf->charsets.elts; - table = charsets[lcf->source_charset].tables[lcf->default_charset]; + table = charsets[lcf->source_charset].tables[lcf->charset]; for (cl = in; cl; cl = cl->next) { - ngx_charset_recode(cl->buf, table); + ngx_http_charset_recode(cl->buf, table); } return ngx_http_next_body_filter(r, in); @@ -229,7 +233,7 @@ ngx_http_charset_body_filter(ngx_http_request_t *r, ngx_chain_t *in) static ngx_uint_t -ngx_charset_recode(ngx_buf_t *b, char *table) +ngx_http_charset_recode(ngx_buf_t *b, char *table) { u_char *p; ngx_uint_t change; @@ -385,7 +389,6 @@ ngx_http_set_charset_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) ngx_int_t *cp; ngx_str_t *value; - ngx_http_charset_t *charset; ngx_http_charset_main_conf_t *mcf; cp = (ngx_int_t *) (p + cmd->offset); @@ -394,21 +397,23 @@ ngx_http_set_charset_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) return "is duplicate"; } + value = cf->args->elts; + + if (cmd->offset == offsetof(ngx_http_charset_loc_conf_t, charset) + && ngx_strcmp(value[1].data, "off") == 0) + { + *cp = NGX_HTTP_NO_CHARSET; + return NGX_CONF_OK; + } + mcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_charset_filter_module); - value = cf->args->elts; - *cp = ngx_http_add_charset(&mcf->charsets, &value[1]); if (*cp == NGX_ERROR) { return NGX_CONF_ERROR; } - if (cmd->offset == offsetof(ngx_http_charset_loc_conf_t, source_charset)) { - charset = mcf->charsets.elts; - charset[*cp].server = 1; - } - return NGX_CONF_OK; } @@ -441,7 +446,6 @@ ngx_http_add_charset(ngx_array_t *charsets, ngx_str_t *name) c->tables = NULL; c->name = *name; - c->server = 0; if (ngx_strcasecmp(name->data, "utf-8") == 0) { c->utf8 = 1; @@ -475,79 +479,24 @@ ngx_http_charset_create_main_conf(ngx_conf_t *cf) } if (ngx_array_init(&mcf->charsets, cf->pool, 2, sizeof(ngx_http_charset_t)) - == NGX_ERROR) + == NGX_ERROR) { return NGX_CONF_ERROR; } - if (ngx_array_init(&mcf->tables, cf->pool, 4, + if (ngx_array_init(&mcf->tables, cf->pool, 1, sizeof(ngx_http_charset_tables_t)) == NGX_ERROR) { return NGX_CONF_ERROR; } - return mcf; -} - - -static char * -ngx_http_charset_init_main_conf(ngx_conf_t *cf, void *conf) -{ - ngx_http_charset_main_conf_t *mcf = conf; - - ngx_uint_t i, n; - ngx_http_charset_t *charset; - ngx_http_charset_tables_t *tables; - - tables = mcf->tables.elts; - charset = mcf->charsets.elts; - - for (i = 0; i < mcf->charsets.nelts; i++) { - if (!charset[i].server) { - continue; - } - - charset[i].tables = ngx_pcalloc(cf->pool, - sizeof(char *) * mcf->charsets.nelts); - if (charset[i].tables == NULL) { - return NGX_CONF_ERROR; - } - - for (n = 0; n < mcf->tables.nelts; n++) { - if ((ngx_int_t) i == tables[n].src) { - charset[i].tables[tables[n].dst] = tables[n].src2dst; - continue; - } - - if ((ngx_int_t) i == tables[n].dst) { - charset[i].tables[tables[n].src] = tables[n].dst2src; - } - } - } - - for (i = 0; i < mcf->charsets.nelts; i++) { - if (!charset[i].server) { - continue; - } - - for (n = 0; n < mcf->charsets.nelts; n++) { - if (i == n) { - continue; - } - - if (charset[i].tables[n]) { - continue; - } - - ngx_log_error(NGX_LOG_EMERG, cf->log, 0, - " no \"charset_map\" between the charsets " - "\"%V\" and \"%V\"", - &charset[i].name, &charset[n].name); - return NGX_CONF_ERROR; - } + if (ngx_array_init(&mcf->recodes, cf->pool, 2, + sizeof(ngx_http_charset_recode_t)) == NGX_ERROR) + { + return NGX_CONF_ERROR; } - return NGX_CONF_OK; + return mcf; } @@ -561,8 +510,7 @@ ngx_http_charset_create_loc_conf(ngx_conf_t *cf) return NGX_CONF_ERROR; } - lcf->enable = NGX_CONF_UNSET; - lcf->default_charset = NGX_CONF_UNSET; + lcf->charset = NGX_CONF_UNSET; lcf->source_charset = NGX_CONF_UNSET; return lcf; @@ -575,37 +523,95 @@ ngx_http_charset_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) ngx_http_charset_loc_conf_t *prev = parent; ngx_http_charset_loc_conf_t *conf = child; - ngx_conf_merge_value(conf->enable, prev->enable, 0); + ngx_uint_t i; + ngx_http_charset_recode_t *recode; + ngx_http_charset_main_conf_t *mcf; - if (conf->default_charset == NGX_CONF_UNSET) { - conf->default_charset = prev->default_charset; - } + ngx_conf_merge_value(conf->charset, prev->charset, NGX_HTTP_NO_CHARSET); if (conf->source_charset == NGX_CONF_UNSET) { conf->source_charset = prev->source_charset; } - if (conf->default_charset == NGX_CONF_UNSET - && conf->source_charset != NGX_CONF_UNSET) + if (conf->charset == NGX_HTTP_NO_CHARSET + || conf->source_charset == NGX_CONF_UNSET + || conf->charset == conf->source_charset) { - conf->default_charset = conf->source_charset; + return NGX_CONF_OK; } - if (conf->source_charset == NGX_CONF_UNSET - && conf->default_charset != NGX_CONF_UNSET) - { - conf->source_charset = conf->default_charset; + mcf = ngx_http_conf_get_module_main_conf(cf, + ngx_http_charset_filter_module); + recode = mcf->recodes.elts; + for (i = 0; i < mcf->recodes.nelts; i++) { + if (conf->source_charset == recode[i].src + && conf->charset == recode[i].dst) + { + return NGX_CONF_OK; + } } - if (conf->enable - && (conf->default_charset == NGX_CONF_UNSET - || conf->source_charset == NGX_CONF_UNSET)) - { - ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, - "the \"source_charset\" or \"default_charset\" " - "must be specified when \"charset\" is on"); + recode = ngx_array_push(&mcf->recodes); + if (recode == NULL) { return NGX_CONF_ERROR; } + recode->src = conf->source_charset; + recode->dst = conf->charset; + return NGX_CONF_OK; } + + +static ngx_int_t +ngx_http_charset_postconfiguration(ngx_conf_t *cf) +{ + ngx_int_t c; + ngx_uint_t i, t; + ngx_http_charset_t *charset; + ngx_http_charset_recode_t *recode; + ngx_http_charset_tables_t *tables; + ngx_http_charset_main_conf_t *mcf; + + mcf = ngx_http_conf_get_module_main_conf(cf, + ngx_http_charset_filter_module); + + recode = mcf->recodes.elts; + tables = mcf->tables.elts; + charset = mcf->charsets.elts; + + for (i = 0; i < mcf->recodes.nelts; i++) { + + c = recode[i].src; + + charset[c].tables = ngx_pcalloc(cf->pool, + sizeof(char *) * mcf->charsets.nelts); + if (charset[c].tables == NULL) { + return NGX_ERROR; + } + + for (t = 0; t < mcf->tables.nelts; t++) { + + if (c == tables[t].src && recode[i].dst == tables[t].dst) { + charset[c].tables[tables[t].dst] = tables[t].src2dst; + goto next; + } + + if (c == tables[t].dst && recode[i].dst == tables[t].src) { + charset[c].tables[tables[t].src] = tables[t].dst2src; + goto next; + } + } + + ngx_log_error(NGX_LOG_EMERG, cf->log, 0, + " no \"charset_map\" between the charsets " + "\"%V\" and \"%V\"", + &charset[c].name, &charset[recode[i].dst].name); + return NGX_ERROR; + + next: + continue; + } + + return NGX_OK; +} diff --git a/src/http/modules/ngx_http_fastcgi_module.c b/src/http/modules/ngx_http_fastcgi_module.c index 0e74528d7..480a22895 100644 --- a/src/http/modules/ngx_http_fastcgi_module.c +++ b/src/http/modules/ngx_http_fastcgi_module.c @@ -277,7 +277,7 @@ static ngx_command_t ngx_http_fastcgi_commands[] = { NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, ngx_conf_set_size_slot, NGX_HTTP_LOC_CONF_OFFSET, - offsetof(ngx_http_fastcgi_loc_conf_t, upstream.busy_buffers_size), + offsetof(ngx_http_fastcgi_loc_conf_t, upstream.busy_buffers_size_conf), NULL }, { ngx_string("fastcgi_temp_path"), @@ -291,14 +291,14 @@ static ngx_command_t ngx_http_fastcgi_commands[] = { NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, ngx_conf_set_size_slot, NGX_HTTP_LOC_CONF_OFFSET, - offsetof(ngx_http_fastcgi_loc_conf_t, upstream.max_temp_file_size), + offsetof(ngx_http_fastcgi_loc_conf_t, upstream.max_temp_file_size_conf), NULL }, { ngx_string("fastcgi_temp_file_write_size"), NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, ngx_conf_set_size_slot, NGX_HTTP_LOC_CONF_OFFSET, - offsetof(ngx_http_fastcgi_loc_conf_t, upstream.temp_file_write_size), + offsetof(ngx_http_fastcgi_loc_conf_t, upstream.temp_file_write_size_conf), NULL }, { ngx_string("fastcgi_next_upstream"), @@ -1001,16 +1001,16 @@ ngx_http_fastcgi_process_header(ngx_http_request_t *r) return NGX_HTTP_INTERNAL_SERVER_ERROR; } - r->headers_out.status = status; - r->headers_out.status_line = *status_line; + u->headers_in.status_n = status; + u->headers_in.status_line = *status_line; } else { - r->headers_out.status = 200; - r->headers_out.status_line.len = sizeof("200 OK") - 1; - r->headers_out.status_line.data = (u_char *) "200 OK"; + u->headers_in.status_n = 200; + u->headers_in.status_line.len = sizeof("200 OK") - 1; + u->headers_in.status_line.data = (u_char *) "200 OK"; } - u->state->status = r->headers_out.status; + u->state->status = u->headers_in.status_n; #if 0 if (u->cachable) { u->cachable = ngx_http_upstream_is_cachable(r); @@ -1452,9 +1452,10 @@ ngx_http_fastcgi_create_loc_conf(ngx_conf_t *cf) conf->upstream.send_lowat = NGX_CONF_UNSET_SIZE; conf->upstream.header_buffer_size = NGX_CONF_UNSET_SIZE; - conf->upstream.busy_buffers_size = NGX_CONF_UNSET_SIZE; - conf->upstream.max_temp_file_size = NGX_CONF_UNSET_SIZE; - conf->upstream.temp_file_write_size = NGX_CONF_UNSET_SIZE; + + conf->upstream.busy_buffers_size_conf = NGX_CONF_UNSET_SIZE; + 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; @@ -1523,23 +1524,28 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) } - ngx_conf_merge_size_value(conf->upstream.busy_buffers_size, - prev->upstream.busy_buffers_size, + ngx_conf_merge_size_value(conf->upstream.busy_buffers_size_conf, + prev->upstream.busy_buffers_size_conf, NGX_CONF_UNSET_SIZE); - if (conf->upstream.busy_buffers_size == NGX_CONF_UNSET_SIZE) { + if (conf->upstream.busy_buffers_size_conf == NGX_CONF_UNSET_SIZE) { conf->upstream.busy_buffers_size = 2 * size; + } else { + conf->upstream.busy_buffers_size = + conf->upstream.busy_buffers_size_conf; + } - } else if (conf->upstream.busy_buffers_size < size) { + if (conf->upstream.busy_buffers_size < size) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "\"fastcgi_busy_buffers_size\" must be equal or bigger than " "maximum of the value of \"fastcgi_header_buffer_size\" and " "one of the \"fastcgi_buffers\""); return NGX_CONF_ERROR; + } - } else if (conf->upstream.busy_buffers_size - > (conf->upstream.bufs.num - 1) * conf->upstream.bufs.size) + if (conf->upstream.busy_buffers_size + > (conf->upstream.bufs.num - 1) * conf->upstream.bufs.size) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "\"fastcgi_busy_buffers_size\" must be less than " @@ -1549,14 +1555,18 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) } - ngx_conf_merge_size_value(conf->upstream.temp_file_write_size, - prev->upstream.temp_file_write_size, + ngx_conf_merge_size_value(conf->upstream.temp_file_write_size_conf, + prev->upstream.temp_file_write_size_conf, NGX_CONF_UNSET_SIZE); - if (conf->upstream.temp_file_write_size == NGX_CONF_UNSET_SIZE) { + if (conf->upstream.temp_file_write_size_conf == NGX_CONF_UNSET_SIZE) { conf->upstream.temp_file_write_size = 2 * size; + } else { + conf->upstream.temp_file_write_size = + conf->upstream.temp_file_write_size_conf; + } - } else if (conf->upstream.temp_file_write_size < size) { + if (conf->upstream.temp_file_write_size < size) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "\"fastcgi_temp_file_write_size\" must be equal or bigger than " "maximum of the value of \"fastcgi_header_buffer_size\" and " @@ -1566,16 +1576,19 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) } - ngx_conf_merge_size_value(conf->upstream.max_temp_file_size, - prev->upstream.max_temp_file_size, + ngx_conf_merge_size_value(conf->upstream.max_temp_file_size_conf, + prev->upstream.max_temp_file_size_conf, NGX_CONF_UNSET_SIZE); - if (conf->upstream.max_temp_file_size == NGX_CONF_UNSET_SIZE) { - + if (conf->upstream.max_temp_file_size_conf == NGX_CONF_UNSET_SIZE) { conf->upstream.max_temp_file_size = 1024 * 1024 * 1024; + } else { + conf->upstream.max_temp_file_size = + conf->upstream.max_temp_file_size_conf; + } - } else if (conf->upstream.max_temp_file_size != 0 - && conf->upstream.max_temp_file_size < size) + if (conf->upstream.max_temp_file_size != 0 + && conf->upstream.max_temp_file_size < size) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "\"fastcgi_max_temp_file_size\" must be equal to zero to disable " @@ -1598,7 +1611,7 @@ 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_msec_value(conf->upstream.pass_unparsed_uri, + 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) { @@ -1617,10 +1630,10 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) ngx_conf_merge_value(conf->upstream.pass_request_body, prev->upstream.pass_request_body, 1); - ngx_conf_merge_msec_value(conf->upstream.redirect_errors, + ngx_conf_merge_value(conf->upstream.redirect_errors, prev->upstream.redirect_errors, 0); - ngx_conf_merge_msec_value(conf->upstream.pass_x_powered_by, + ngx_conf_merge_value(conf->upstream.pass_x_powered_by, prev->upstream.pass_x_powered_by, 1); @@ -1628,7 +1641,6 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) if (conf->peers == NULL) { conf->peers = prev->peers; - conf->upstream = prev->upstream; } if (conf->params_source == NULL) { diff --git a/src/http/modules/ngx_http_gzip_filter_module.c b/src/http/modules/ngx_http_gzip_filter_module.c index 596e52403..024302807 100644 --- a/src/http/modules/ngx_http_gzip_filter_module.c +++ b/src/http/modules/ngx_http_gzip_filter_module.c @@ -174,7 +174,7 @@ static ngx_command_t ngx_http_gzip_filter_commands[] = { NULL }, { ngx_string("gzip_http_version"), - NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_ANY, + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, ngx_conf_set_enum_slot, NGX_HTTP_LOC_CONF_OFFSET, offsetof(ngx_http_gzip_conf_t, http_version), diff --git a/src/http/modules/ngx_http_proxy_module.c b/src/http/modules/ngx_http_proxy_module.c index 85503d0ac..92605e060 100644 --- a/src/http/modules/ngx_http_proxy_module.c +++ b/src/http/modules/ngx_http_proxy_module.c @@ -219,7 +219,7 @@ static ngx_command_t ngx_http_proxy_commands[] = { NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, ngx_conf_set_size_slot, NGX_HTTP_LOC_CONF_OFFSET, - offsetof(ngx_http_proxy_loc_conf_t, upstream.busy_buffers_size), + offsetof(ngx_http_proxy_loc_conf_t, upstream.busy_buffers_size_conf), NULL }, { ngx_string("proxy_temp_path"), @@ -233,14 +233,14 @@ static ngx_command_t ngx_http_proxy_commands[] = { NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, ngx_conf_set_size_slot, NGX_HTTP_LOC_CONF_OFFSET, - offsetof(ngx_http_proxy_loc_conf_t, upstream.max_temp_file_size), + offsetof(ngx_http_proxy_loc_conf_t, upstream.max_temp_file_size_conf), NULL }, { ngx_string("proxy_temp_file_write_size"), NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, ngx_conf_set_size_slot, NGX_HTTP_LOC_CONF_OFFSET, - offsetof(ngx_http_proxy_loc_conf_t, upstream.temp_file_write_size), + offsetof(ngx_http_proxy_loc_conf_t, upstream.temp_file_write_size_conf), NULL }, { ngx_string("proxy_next_upstream"), @@ -720,21 +720,21 @@ ngx_http_proxy_process_status_line(ngx_http_request_t *r) return NGX_OK; } - r->headers_out.status = p->status; + u->headers_in.status_n = p->status; u->state->status = p->status; - r->headers_out.status_line.len = p->status_end - p->status_start; - r->headers_out.status_line.data = ngx_palloc(r->pool, - r->headers_out.status_line.len); - if (r->headers_out.status_line.data == NULL) { + u->headers_in.status_line.len = p->status_end - p->status_start; + u->headers_in.status_line.data = ngx_palloc(r->pool, + u->headers_in.status_line.len); + if (u->headers_in.status_line.data == NULL) { return NGX_HTTP_INTERNAL_SERVER_ERROR; } - ngx_memcpy(r->headers_out.status_line.data, p->status_start, - r->headers_out.status_line.len); + ngx_memcpy(u->headers_in.status_line.data, p->status_start, + u->headers_in.status_line.len); ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "http proxy status %ui \"%V\"", - r->headers_out.status, &r->headers_out.status_line); + u->headers_in.status, &u->headers_in.status_line); u->process_header = ngx_http_proxy_process_header; @@ -1301,9 +1301,10 @@ ngx_http_proxy_create_loc_conf(ngx_conf_t *cf) conf->upstream.send_lowat = NGX_CONF_UNSET_SIZE; conf->upstream.header_buffer_size = NGX_CONF_UNSET_SIZE; - conf->upstream.busy_buffers_size = NGX_CONF_UNSET_SIZE; - conf->upstream.max_temp_file_size = NGX_CONF_UNSET_SIZE; - conf->upstream.temp_file_write_size = NGX_CONF_UNSET_SIZE; + + conf->upstream.busy_buffers_size_conf = NGX_CONF_UNSET_SIZE; + 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; @@ -1374,23 +1375,28 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) } - ngx_conf_merge_size_value(conf->upstream.busy_buffers_size, - prev->upstream.busy_buffers_size, + ngx_conf_merge_size_value(conf->upstream.busy_buffers_size_conf, + prev->upstream.busy_buffers_size_conf, NGX_CONF_UNSET_SIZE); - if (conf->upstream.busy_buffers_size == NGX_CONF_UNSET_SIZE) { + if (conf->upstream.busy_buffers_size_conf == NGX_CONF_UNSET_SIZE) { conf->upstream.busy_buffers_size = 2 * size; - - } else if (conf->upstream.busy_buffers_size < size) { + } else { + conf->upstream.busy_buffers_size = + conf->upstream.busy_buffers_size_conf; + } + + if (conf->upstream.busy_buffers_size < size) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "\"proxy_busy_buffers_size\" must be equal or bigger than " "maximum of the value of \"proxy_header_buffer_size\" and " "one of the \"proxy_buffers\""); return NGX_CONF_ERROR; + } - } else if (conf->upstream.busy_buffers_size - > (conf->upstream.bufs.num - 1) * conf->upstream.bufs.size) + if (conf->upstream.busy_buffers_size + > (conf->upstream.bufs.num - 1) * conf->upstream.bufs.size) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "\"proxy_busy_buffers_size\" must be less than " @@ -1398,16 +1404,20 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) return NGX_CONF_ERROR; } - - ngx_conf_merge_size_value(conf->upstream.temp_file_write_size, - prev->upstream.temp_file_write_size, + + ngx_conf_merge_size_value(conf->upstream.temp_file_write_size_conf, + prev->upstream.temp_file_write_size_conf, NGX_CONF_UNSET_SIZE); - if (conf->upstream.temp_file_write_size == NGX_CONF_UNSET_SIZE) { + if (conf->upstream.temp_file_write_size_conf == NGX_CONF_UNSET_SIZE) { conf->upstream.temp_file_write_size = 2 * size; - - } else if (conf->upstream.temp_file_write_size < size) { + } else { + conf->upstream.temp_file_write_size = + conf->upstream.temp_file_write_size_conf; + } + + if (conf->upstream.temp_file_write_size < size) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "\"proxy_temp_file_write_size\" must be equal or bigger than " "maximum of the value of \"proxy_header_buffer_size\" and " @@ -1416,17 +1426,19 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) return NGX_CONF_ERROR; } - - ngx_conf_merge_size_value(conf->upstream.max_temp_file_size, - prev->upstream.max_temp_file_size, + ngx_conf_merge_size_value(conf->upstream.max_temp_file_size_conf, + prev->upstream.max_temp_file_size_conf, NGX_CONF_UNSET_SIZE); - if (conf->upstream.max_temp_file_size == NGX_CONF_UNSET_SIZE) { - + if (conf->upstream.max_temp_file_size_conf == NGX_CONF_UNSET_SIZE) { conf->upstream.max_temp_file_size = 1024 * 1024 * 1024; + } else { + conf->upstream.max_temp_file_size = + conf->upstream.max_temp_file_size_conf; + } - } else if (conf->upstream.max_temp_file_size != 0 - && conf->upstream.max_temp_file_size < size) + if (conf->upstream.max_temp_file_size != 0 + && conf->upstream.max_temp_file_size < size) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "\"fastcgi_max_temp_file_size\" must be equal to zero to disable " @@ -1437,6 +1449,7 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) return NGX_CONF_ERROR; } + ngx_conf_merge_bitmask_value(conf->upstream.next_upstream, prev->upstream.next_upstream, (NGX_CONF_BITMASK_SET @@ -1448,7 +1461,7 @@ 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_msec_value(conf->upstream.pass_unparsed_uri, + 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) { @@ -1467,14 +1480,14 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) ngx_conf_merge_value(conf->upstream.pass_request_body, prev->upstream.pass_request_body, 1); - ngx_conf_merge_msec_value(conf->upstream.redirect_errors, + ngx_conf_merge_value(conf->upstream.redirect_errors, prev->upstream.redirect_errors, 0); - ngx_conf_merge_msec_value(conf->upstream.pass_x_powered_by, + ngx_conf_merge_value(conf->upstream.pass_x_powered_by, prev->upstream.pass_x_powered_by, 1); - ngx_conf_merge_msec_value(conf->upstream.pass_server, + ngx_conf_merge_value(conf->upstream.pass_server, prev->upstream.pass_server, 0); - ngx_conf_merge_msec_value(conf->upstream.pass_x_accel_expires, + ngx_conf_merge_value(conf->upstream.pass_x_accel_expires, prev->upstream.pass_x_accel_expires, 0); @@ -1508,7 +1521,6 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) if (conf->peers == NULL) { conf->peers = prev->peers; - conf->upstream = prev->upstream; } if (conf->headers_source == NULL) { diff --git a/src/http/modules/ngx_http_ssi_filter_module.c b/src/http/modules/ngx_http_ssi_filter_module.c index 856726a35..bf9c12411 100644 --- a/src/http/modules/ngx_http_ssi_filter_module.c +++ b/src/http/modules/ngx_http_ssi_filter_module.c @@ -1373,8 +1373,8 @@ static ngx_int_t ngx_http_ssi_include(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, ngx_str_t **params) { - u_char ch, *p, **value; - size_t *size, len; + u_char ch, *p, **value, *data; + size_t *size, len, prefix; ngx_uint_t i, j, n, bracket; ngx_str_t uri, args, name; ngx_array_t lengths, values; @@ -1385,6 +1385,7 @@ ngx_http_ssi_include(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, uri = *params[NGX_HTTP_SSI_INCLUDE_VIRTUAL]; args.len = 0; args.data = NULL; + prefix = 0; n = ngx_http_script_variables_count(&uri); @@ -1497,6 +1498,24 @@ ngx_http_ssi_include(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, *value = name.data; } + size = lengths.elts; + value = values.elts; + + for (i = 0; i < values.nelts; i++) { + if (size[i] != 0) { + if (*value[i] != '/') { + for (prefix = r->uri.len; prefix; prefix--) { + if (r->uri.data[prefix - 1] == '/') { + len += prefix; + break; + } + } + } + + break; + } + } + p = ngx_palloc(r->pool, len); if (p == NULL) { return NGX_HTTP_SSI_ERROR; @@ -1505,12 +1524,37 @@ ngx_http_ssi_include(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, uri.len = len; uri.data = p; - size = lengths.elts; - value = values.elts; + if (prefix) { + p = ngx_cpymem(p, r->uri.data, prefix); + } for (i = 0; i < values.nelts; i++) { p = ngx_cpymem(p, value[i], size[i]); } + + } else { + if (uri.data[0] != '/') { + for (prefix = r->uri.len; prefix; prefix--) { + if (r->uri.data[prefix - 1] == '/') { + break; + } + } + + if (prefix) { + len = prefix + uri.len; + + data = ngx_palloc(r->pool, len); + if (data == NULL) { + return NGX_HTTP_SSI_ERROR; + } + + p = ngx_cpymem(data, r->uri.data, prefix); + ngx_memcpy(p, uri.data, uri.len); + + uri.len = len; + uri.data = data; + } + } } for (i = 0; i < uri.len; i++) { diff --git a/src/http/modules/ngx_http_ssl_module.c b/src/http/modules/ngx_http_ssl_module.c index 04d4c9100..bf1d24fc7 100644 --- a/src/http/modules/ngx_http_ssl_module.c +++ b/src/http/modules/ngx_http_ssl_module.c @@ -221,18 +221,19 @@ ngx_http_ssl_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child) } } - if (SSL_CTX_use_certificate_file(conf->ssl_ctx, - (char *) conf->certificate.data, - SSL_FILETYPE_PEM) == 0) { + if (SSL_CTX_use_certificate_chain_file(conf->ssl_ctx, + (char *) conf->certificate.data) == 0) + { ngx_ssl_error(NGX_LOG_EMERG, cf->log, 0, - "SSL_CTX_use_certificate_file(\"%s\") failed", + "SSL_CTX_use_certificate_chain_file(\"%s\") failed", conf->certificate.data); return NGX_CONF_ERROR; } if (SSL_CTX_use_PrivateKey_file(conf->ssl_ctx, (char *) conf->certificate_key.data, - SSL_FILETYPE_PEM) == 0) { + SSL_FILETYPE_PEM) == 0) + { ngx_ssl_error(NGX_LOG_EMERG, cf->log, 0, "SSL_CTX_use_PrivateKey_file(\"%s\") failed", conf->certificate_key.data); |