summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES36
-rw-r--r--CHANGES.ru36
-rw-r--r--auto/options4
-rw-r--r--conf/nginx.conf3
-rw-r--r--src/core/nginx.h2
-rw-r--r--src/http/modules/ngx_http_autoindex_module.c14
-rw-r--r--src/http/modules/ngx_http_charset_filter_module.c252
-rw-r--r--src/http/modules/ngx_http_fastcgi_module.c76
-rw-r--r--src/http/modules/ngx_http_gzip_filter_module.c2
-rw-r--r--src/http/modules/ngx_http_proxy_module.c92
-rw-r--r--src/http/modules/ngx_http_ssi_filter_module.c52
-rw-r--r--src/http/modules/ngx_http_ssl_module.c11
-rw-r--r--src/http/ngx_http_upstream.c54
-rw-r--r--src/http/ngx_http_upstream.h9
-rw-r--r--src/imap/ngx_imap_handler.c4
-rw-r--r--src/imap/ngx_imap_parse.c5
-rw-r--r--src/imap/ngx_imap_proxy_module.c36
-rw-r--r--src/os/unix/ngx_user.c4
18 files changed, 453 insertions, 239 deletions
diff --git a/CHANGES b/CHANGES
index 98a7a97f0..a06ba7931 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,40 @@
+Changes with nginx 0.1.39 14 Jul 2005
+
+ *) 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.
+
+
Changes with nginx 0.1.38 08 Jul 2005
*) Feature: the "limit_rate" directive is supported in in proxy and
diff --git a/CHANGES.ru b/CHANGES.ru
index d60d4220e..1b6e4d3a0 100644
--- a/CHANGES.ru
+++ b/CHANGES.ru
@@ -1,4 +1,40 @@
+Изменения в nginx 0.1.39 14.07.2005
+
+ *) Изменения в модуле ngx_http_charset_module: директива
+ default_charset упразднена; директива charset задаёт кодировку
+ ответа; директива source_charset задаёт только исходную кодировку.
+
+ *) Исправление: при перенаправлении ошибки 401, полученной от бэкенда,
+ не передавалась строка заголовка "WWW-Authenticate".
+
+ *) Исправление: модули ngx_http_proxy_module и ngx_http_fastcgi_module
+ могли закрыть соединение до того, как что-нибудь было передано
+ клиенту; ошибка появилась в 0.1.38.
+
+ *) Изменение: обработка ошибки инициализации в crypt_r() в Linux glibc.
+
+ *) Исправление: модуль ngx_http_ssi_module не поддерживал относительные
+ URI в команде include virtual.
+
+ *) Исправление: если в строке заголовка ответа бэкенда была строка
+ "Location", которую nginx не должен был изменять, то в ответе
+ передавалось тело 500 ошибки; ошибка появилась в 0.1.29.
+
+ *) Исправление: некоторые директивы модулей ngx_http_proxy_module и
+ ngx_http_fastcgi_module не наследовались с уровня server на уровень
+ location; ошибка появилась в 0.1.29.
+
+ *) Исправление: модуль ngx_http_ssl_module не поддерживал цепочки
+ сертификатов.
+
+ *) Исправление: ошибка в модуле ngx_http_autoindex_module при показе
+ длинных имён файлов; ошибка появилась в 0.1.38.
+
+ *) Исправления в IMAP/POP3 прокси при взаимодействии с бэкендом на
+ стадии login.
+
+
Изменения в nginx 0.1.38 08.07.2005
*) Добавление: директива limit_rate поддерживается в режиме прокси и
diff --git a/auto/options b/auto/options
index a56bc4271..ad25cc284 100644
--- a/auto/options
+++ b/auto/options
@@ -225,6 +225,10 @@ cat << END
--http-fastcgi-temp-path=PATH set path to the http fastcgi temporary
files path
+ --without-http disable HTTP server
+
+ --with-imap enable IMAP4/POP3 proxy module
+
--with-cc=PATH set path to C compiler
--with-cpp=PATH set path to C preprocessor
--with-cc-opt=OPTIONS set additional options for C compiler
diff --git a/conf/nginx.conf b/conf/nginx.conf
index a4c1fc5e7..542fda2d3 100644
--- a/conf/nginx.conf
+++ b/conf/nginx.conf
@@ -25,8 +25,7 @@ http {
server {
listen 80;
- charset on;
- source_charset koi8-r;
+ charset koi8-r;
#access_log logs/access.log;
diff --git a/src/core/nginx.h b/src/core/nginx.h
index 221ba38f0..4b800e72d 100644
--- a/src/core/nginx.h
+++ b/src/core/nginx.h
@@ -8,7 +8,7 @@
#define _NGINX_H_INCLUDED_
-#define NGINX_VER "nginx/0.1.38"
+#define NGINX_VER "nginx/0.1.39"
#define NGINX_VAR "NGINX"
#define NGX_NEWPID_EXT ".newbin"
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("&gt;") - 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);
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
index 8571b869b..4b877a3fb 100644
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -103,6 +103,11 @@ ngx_http_upstream_header_t ngx_http_upstream_headers_in[] = {
ngx_http_upstream_conditional_copy_header_line,
offsetof(ngx_http_upstream_conf_t, pass_server), 0 },
+ { ngx_string("WWW-Authenticate"),
+ ngx_http_upstream_process_header_line,
+ offsetof(ngx_http_upstream_headers_in_t, www_authenticate),
+ ngx_http_upstream_copy_header_line, 0, 0 },
+
{ ngx_string("Location"),
ngx_http_upstream_ignore_header_line, 0,
ngx_http_upstream_rewrite_location, 0, 0 },
@@ -113,7 +118,7 @@ ngx_http_upstream_header_t ngx_http_upstream_headers_in[] = {
{ ngx_string("Set-Cookie"),
ngx_http_upstream_ignore_header_line, 0,
- ngx_http_upstream_copy_header_line, 0, 1 },
+ ngx_http_upstream_copy_header_line, 0, 0 },
{ ngx_string("Cache-Control"),
ngx_http_upstream_process_multi_header_lines,
@@ -386,9 +391,6 @@ ngx_http_upstream_check_broken_connection(ngx_http_request_t *r,
return;
}
- ev->eof = 1;
- c->closed = 1;
-
if (n == -1) {
if (err == NGX_EAGAIN) {
return;
@@ -400,6 +402,9 @@ ngx_http_upstream_check_broken_connection(ngx_http_request_t *r,
err = 0;
}
+ ev->eof = 1;
+ c->closed = 1;
+
if (!u->cachable && u->peer.connection) {
ngx_log_error(NGX_LOG_INFO, ev->log, err,
"client closed prematurely connection, "
@@ -851,7 +856,7 @@ ngx_http_upstream_process_header(ngx_event_t *rev)
/* rc == NGX_OK */
- if (r->headers_out.status == NGX_HTTP_INTERNAL_SERVER_ERROR) {
+ if (u->headers_in.status_n == NGX_HTTP_INTERNAL_SERVER_ERROR) {
if (u->peer.tries > 1
&& (u->conf->next_upstream & NGX_HTTP_UPSTREAM_FT_HTTP_500))
@@ -867,14 +872,14 @@ ngx_http_upstream_process_header(ngx_event_t *rev)
&& (u->conf->use_stale & NGX_HTTP_UPSTREAM_FT_HTTP_500))
{
ngx_http_upstream_finalize_request(r, u,
- ngx_http_send_cached_response(r));
+ ngx_http_send_cached_response(r));
return;
}
#endif
}
- if (r->headers_out.status == NGX_HTTP_NOT_FOUND
+ if (u->headers_in.status_n == NGX_HTTP_NOT_FOUND
&& u->peer.tries > 1
&& u->conf->next_upstream & NGX_HTTP_UPSTREAM_FT_HTTP_404)
{
@@ -883,7 +888,7 @@ ngx_http_upstream_process_header(ngx_event_t *rev)
}
- if (r->headers_out.status >= NGX_HTTP_BAD_REQUEST
+ if (u->headers_in.status_n >= NGX_HTTP_BAD_REQUEST
&& u->conf->redirect_errors
&& r->err_ctx == NULL)
{
@@ -893,9 +898,25 @@ ngx_http_upstream_process_header(ngx_event_t *rev)
err_page = clcf->error_pages->elts;
for (i = 0; i < clcf->error_pages->nelts; i++) {
- if (err_page[i].status == (ngx_int_t) r->headers_out.status) {
+ if (err_page[i].status == (ngx_int_t) u->headers_in.status_n) {
+
+ if (u->headers_in.status_n == NGX_HTTP_UNAUTHORIZED) {
+
+ r->headers_out.www_authenticate =
+ ngx_list_push(&r->headers_out.headers);
+
+ if (r->headers_out.www_authenticate == NULL) {
+ ngx_http_upstream_finalize_request(r, u,
+ NGX_HTTP_INTERNAL_SERVER_ERROR);
+ return;
+ }
+
+ *r->headers_out.www_authenticate =
+ *u->headers_in.www_authenticate;
+ }
+
ngx_http_upstream_finalize_request(r, u,
- r->headers_out.status);
+ u->headers_in.status_n);
return;
}
}
@@ -938,8 +959,6 @@ ngx_http_upstream_process_header(ngx_event_t *rev)
}
}
- r->headers_out.status_line.len = 0;
-
ngx_http_internal_redirect(r,
&r->upstream->headers_in.x_accel_redirect->value,
NULL);
@@ -1001,6 +1020,9 @@ ngx_http_upstream_send_response(ngx_http_request_t *r, ngx_http_upstream_t *u)
}
}
+ r->headers_out.status = u->headers_in.status_n;
+ r->headers_out.status_line = u->headers_in.status_line;
+
rc = ngx_http_send_header(r);
if (rc == NGX_ERROR || rc > NGX_OK) {
@@ -1622,6 +1644,10 @@ ngx_http_upstream_rewrite_location(ngx_http_request_t *r, ngx_table_elt_t *h,
if (r->upstream->rewrite_redirect) {
rc = r->upstream->rewrite_redirect(r, ho, 0);
+ if (rc == NGX_DECLINED) {
+ return NGX_OK;
+ }
+
if (rc == NGX_OK) {
r->headers_out.location = ho;
@@ -1667,6 +1693,10 @@ ngx_http_upstream_rewrite_refresh(ngx_http_request_t *r, ngx_table_elt_t *h,
return NGX_OK;
}
+ if (rc == NGX_DECLINED) {
+ return NGX_OK;
+ }
+
#if (NGX_DEBUG)
if (rc == NGX_OK) {
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
diff --git a/src/http/ngx_http_upstream.h b/src/http/ngx_http_upstream.h
index 428253c42..a38f65b6b 100644
--- a/src/http/ngx_http_upstream.h
+++ b/src/http/ngx_http_upstream.h
@@ -52,10 +52,15 @@ typedef struct {
size_t send_lowat;
size_t header_buffer_size;
+
size_t busy_buffers_size;
size_t max_temp_file_size;
size_t temp_file_write_size;
+ size_t busy_buffers_size_conf;
+ size_t max_temp_file_size_conf;
+ size_t temp_file_write_size_conf;
+
ngx_uint_t next_upstream;
ngx_uint_t method;
@@ -95,6 +100,9 @@ typedef struct {
typedef struct {
ngx_list_t headers;
+ ngx_uint_t status_n;
+ ngx_str_t status_line;
+
ngx_table_elt_t *status;
ngx_table_elt_t *date;
ngx_table_elt_t *server;
@@ -112,6 +120,7 @@ typedef struct {
ngx_table_elt_t *last_modified;
ngx_table_elt_t *location;
ngx_table_elt_t *accept_ranges;
+ ngx_table_elt_t *www_authenticate;
#if (NGX_HTTP_GZIP)
ngx_table_elt_t *content_encoding;
diff --git a/src/imap/ngx_imap_handler.c b/src/imap/ngx_imap_handler.c
index 6464d4a85..25509b2fe 100644
--- a/src/imap/ngx_imap_handler.c
+++ b/src/imap/ngx_imap_handler.c
@@ -16,7 +16,7 @@ static ngx_int_t ngx_imap_read_command(ngx_imap_session_t *s);
static ngx_str_t greetings[] = {
ngx_string("+OK POP3 ready" CRLF),
- ngx_string("* OK IMAP ready" CRLF)
+ ngx_string("* OK IMAP4 ready" CRLF)
};
static ngx_str_t internal_server_errors[] = {
@@ -27,7 +27,7 @@ static ngx_str_t internal_server_errors[] = {
static u_char pop3_ok[] = "+OK" CRLF;
static u_char pop3_invalid_command[] = "-ERR invalid command" CRLF;
-static u_char imap_ok[] = "OK" CRLF;
+static u_char imap_ok[] = "OK completed" CRLF;
static u_char imap_next[] = "+ OK" CRLF;
static u_char imap_bye[] = "* BYE" CRLF;
static u_char imap_invalid_command[] = "BAD invalid command" CRLF;
diff --git a/src/imap/ngx_imap_parse.c b/src/imap/ngx_imap_parse.c
index e3923e892..374605ec5 100644
--- a/src/imap/ngx_imap_parse.c
+++ b/src/imap/ngx_imap_parse.c
@@ -252,7 +252,7 @@ ngx_int_t ngx_imap_parse_command(ngx_imap_session_t *s)
goto invalid;
case sw_literal_argument:
- if (--s->literal_len) {
+ if (s->literal_len && --s->literal_len) {
break;
}
@@ -281,7 +281,8 @@ ngx_int_t ngx_imap_parse_command(ngx_imap_session_t *s)
case LF:
goto done;
default:
- goto invalid;
+ state = sw_spaces_before_argument;
+ break;
}
break;
diff --git a/src/imap/ngx_imap_proxy_module.c b/src/imap/ngx_imap_proxy_module.c
index 5177e289f..81ddb8397 100644
--- a/src/imap/ngx_imap_proxy_module.c
+++ b/src/imap/ngx_imap_proxy_module.c
@@ -169,11 +169,21 @@ ngx_imap_proxy_imap_handler(ngx_event_t *rev)
return;
}
- if (rc == NGX_ERROR) {
+ if (rc == NGX_ERROR || rc == NGX_IMAP_PROXY_INVALID) {
ngx_imap_proxy_internal_server_error(s);
return;
}
+ if (rc == NGX_IMAP_PROXY_ERROR) {
+ s->connection->read->handler = ngx_imap_proxy_handler;
+ s->connection->write->handler = ngx_imap_proxy_handler;
+ rev->handler = ngx_imap_proxy_handler;
+ c->write->handler = ngx_imap_proxy_handler;
+
+ ngx_imap_proxy_handler(c->read);
+ return;
+ }
+
switch (s->imap_state) {
case ngx_imap_start:
@@ -198,14 +208,14 @@ ngx_imap_proxy_imap_handler(ngx_event_t *rev)
case ngx_imap_login:
ngx_log_debug0(NGX_LOG_DEBUG_IMAP, rev->log, 0, "imap proxy send user");
- line.len = s->login.len + 1 + NGX_SIZE_T_LEN + 1 + 2;
+ line.len = s->login.len + 1 + 1 + NGX_SIZE_T_LEN + 1 + 2;
line.data = ngx_palloc(c->pool, line.len);
if (line.data == NULL) {
ngx_imap_proxy_internal_server_error(s);
return;
}
- line.len = ngx_sprintf(line.data, "%V{%uz}" CRLF,
+ line.len = ngx_sprintf(line.data, "%V {%uz}" CRLF,
&s->login, s->passwd.len)
- line.data;
@@ -298,11 +308,21 @@ ngx_imap_proxy_pop3_handler(ngx_event_t *rev)
return;
}
- if (rc == NGX_ERROR) {
+ if (rc == NGX_ERROR || rc == NGX_IMAP_PROXY_INVALID) {
ngx_imap_proxy_internal_server_error(s);
return;
}
+ if (rc == NGX_IMAP_PROXY_ERROR) {
+ s->connection->read->handler = ngx_imap_proxy_handler;
+ s->connection->write->handler = ngx_imap_proxy_handler;
+ rev->handler = ngx_imap_proxy_handler;
+ c->write->handler = ngx_imap_proxy_handler;
+
+ ngx_imap_proxy_handler(c->read);
+ return;
+ }
+
switch (s->imap_state) {
case ngx_pop3_start:
@@ -424,13 +444,17 @@ ngx_imap_proxy_read_response(ngx_imap_session_t *s, ngx_uint_t what)
}
} else {
+ if (p[0] == 'N' && p[1] == 'O') {
+ return NGX_IMAP_PROXY_ERROR;
+ }
+
if (what == NGX_IMAP_WAIT_OK) {
if (p[0] == '*' && p[1] == ' ' && p[2] == 'O' && p[3] == 'K') {
return NGX_OK;
}
} else {
- if (p[0] == '+' && p[1] == ' ' && p[2] == 'O' && p[3] == 'K') {
+ if (p[0] == '+') {
return NGX_OK;
}
}
@@ -528,7 +552,7 @@ ngx_imap_proxy_handler(ngx_event_t *ev)
if (n == NGX_AGAIN || n < (ssize_t) size) {
if (ngx_handle_write_event(dst->write, /* TODO: LOWAT */ 0)
- == NGX_ERROR)
+ == NGX_ERROR)
{
ngx_imap_proxy_close_session(s);
return;
diff --git a/src/os/unix/ngx_user.c b/src/os/unix/ngx_user.c
index cbb08a852..b40a2b721 100644
--- a/src/os/unix/ngx_user.c
+++ b/src/os/unix/ngx_user.c
@@ -33,8 +33,8 @@ ngx_crypt(ngx_pool_t *pool, u_char *key, u_char *salt, u_char **encrypted)
ngx_set_errno(0);
cd.initialized = 0;
- /* work around the glibc-2.2.5 bug */
- cd.current_saltbits = 0;
+ /* work around the glibc bug */
+ cd.current_salt[0] = ~salt[0];
value = crypt_r((char *) key, (char *) salt, &cd);