# HG changeset patch # User Igor Sysoev # Date 1138050000 -10800 # Node ID 396dbbc06dd729fcbbf5ba5d640cac3c2d45b69a # Parent 843df9f3304de4a85630c4c80a096de03f3ebabd nginx 0.3.23 *) Feature: the "optimize_host_names" directive. *) Bugfix: in using of the variables in the "path" and "alias" directives. *) Bugfix: the ngx_http_perl_module was incorrectly built on Linux and Solaris. diff --git a/CHANGES b/CHANGES --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,14 @@ + +Changes with nginx 0.3.23 24 Jan 2006 + + *) Feature: the "optimize_host_names" directive. + + *) Bugfix: in using of the variables in the "path" and "alias" + directives. + + *) Bugfix: the ngx_http_perl_module was incorrectly built on Linux and + Solaris. + Changes with nginx 0.3.22 17 Jan 2006 diff --git a/CHANGES.ru b/CHANGES.ru --- a/CHANGES.ru +++ b/CHANGES.ru @@ -1,3 +1,14 @@ + +Изменения в nginx 0.3.23 24.01.2006 + + *) Добавление: директива optimize_host_names. + + *) Исправление: ошибки при использовании переменных в директивах path и + alias. + + *) Исправление: модуль ngx_http_perl_module неправильно собирался на + Linux и Solaris. + Изменения в nginx 0.3.22 17.01.2006 diff --git a/src/core/nginx.h b/src/core/nginx.h --- a/src/core/nginx.h +++ b/src/core/nginx.h @@ -8,7 +8,7 @@ #define _NGINX_H_INCLUDED_ -#define NGINX_VER "nginx/0.3.22" +#define NGINX_VER "nginx/0.3.23" #define NGINX_VAR "NGINX" #define NGX_OLDPID_EXT ".oldbin" diff --git a/src/http/modules/ngx_http_referer_module.c b/src/http/modules/ngx_http_referer_module.c --- a/src/http/modules/ngx_http_referer_module.c +++ b/src/http/modules/ngx_http_referer_module.c @@ -216,6 +216,16 @@ ngx_http_referer_merge_conf(ngx_conf_t * return NGX_CONF_OK; } + if ((conf->no_referer == 1 || conf->blocked_referer == 1) + && conf->keys->keys.nelts == 0 && conf->keys->dns_wildcards.nelts) + { + ngx_log_error(NGX_LOG_EMERG, cf->log, 0, + "the \"none\" or \"blocked\" referers are specified " + "in the \"valid_referers\" directive " + "without any valid referer"); + return NGX_CONF_ERROR; + } + hash.key = ngx_hash_key_lc; hash.max_size = 2048; /* TODO: referer_hash_max_size; */ hash.bucket_size = 64; /* TODO: referer_hash_bucket_size; */ diff --git a/src/http/modules/ngx_http_static_module.c b/src/http/modules/ngx_http_static_module.c --- a/src/http/modules/ngx_http_static_module.c +++ b/src/http/modules/ngx_http_static_module.c @@ -186,7 +186,7 @@ ngx_http_static_handler(ngx_http_request clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); - if (!clcf->alias) { + if (!clcf->alias && clcf->root_lengths == NULL) { location = path.data + clcf->root.len; } else { diff --git a/src/http/modules/perl/nginx.pm b/src/http/modules/perl/nginx.pm --- a/src/http/modules/perl/nginx.pm +++ b/src/http/modules/perl/nginx.pm @@ -17,7 +17,7 @@ our @EXPORT = qw( HTTP_SERVER_ERROR ); -our $VERSION = '0.3.22'; +our $VERSION = '0.3.23'; require XSLoader; XSLoader::load('nginx', $VERSION); diff --git a/src/http/modules/perl/nginx.xs b/src/http/modules/perl/nginx.xs --- a/src/http/modules/perl/nginx.xs +++ b/src/http/modules/perl/nginx.xs @@ -6,15 +6,13 @@ #define PERL_NO_GET_CONTEXT -#include "EXTERN.h" -#include "perl.h" -#include "XSUB.h" - #include #include #include #include +#include "XSUB.h" + static ngx_int_t ngx_http_perl_sv2str(pTHX_ ngx_http_request_t *r, ngx_str_t *s, SV *sv) diff --git a/src/http/ngx_http.c b/src/http/ngx_http.c --- a/src/http/ngx_http.c +++ b/src/http/ngx_http.c @@ -76,7 +76,7 @@ ngx_http_block(ngx_conf_t *cf, ngx_comma char *rv; u_char ch; ngx_int_t rc; - ngx_uint_t mi, m, s, l, p, a, n, i; + ngx_uint_t mi, m, s, l, p, a, i; ngx_uint_t last, bind_all, done; ngx_conf_t pcf; ngx_array_t in_ports; @@ -533,16 +533,20 @@ ngx_http_block(ngx_conf_t *cf, ngx_comma /* * check whether all name-based servers have the same configuraiton - * as the default server, or some servers restrict the host names + * as the default server, + * or some servers restrict the host names, + * or some servers disable optimizing the host names */ in_addr = in_port[p].addrs.elts; for (a = 0; a < in_port[p].addrs.nelts; a++) { name = in_addr[a].names.elts; - for (n = 0; n < in_addr[a].names.nelts; n++) { - if (in_addr[a].core_srv_conf != name[n].core_srv_conf - || name[n].core_srv_conf->restrict_host_names + for (s = 0; s < in_addr[a].names.nelts; s++) { + + if (in_addr[a].core_srv_conf != name[s].core_srv_conf + || name[s].core_srv_conf->optimize_host_names == 0 + || name[s].core_srv_conf->restrict_host_names != NGX_HTTP_RESTRICT_HOST_OFF) { goto virtual_names; @@ -551,7 +555,9 @@ ngx_http_block(ngx_conf_t *cf, ngx_comma /* * if all name-based servers have the same configuration - * as the default server, and no servers restrict the host names + * as the default server, + * and no servers restrict the host names, + * and no servers disable optimizing the host names * then we do not need to check them at run-time at all */ diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -136,6 +136,13 @@ static ngx_command_t ngx_http_core_comm offsetof(ngx_http_core_srv_conf_t, restrict_host_names), &ngx_http_restrict_host_names }, + { ngx_string("optimize_host_names"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_FLAG, + ngx_conf_set_flag_slot, + NGX_HTTP_SRV_CONF_OFFSET, + offsetof(ngx_http_core_srv_conf_t, optimize_host_names), + NULL }, + { ngx_string("ignore_invalid_headers"), NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_FLAG, ngx_conf_set_flag_slot, @@ -995,6 +1002,13 @@ ngx_http_map_uri_to_path(ngx_http_reques alias = clcf->alias ? clcf->name.len : 0; + if (alias && !r->valid_location) { + ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, + "\"alias\" could not be used in location \"%V\" " + "where URI was rewritten", &clcf->name); + return NULL; + } + if (clcf->root_lengths == NULL) { r->root_length = clcf->root.len; @@ -1826,6 +1840,7 @@ ngx_http_core_create_srv_conf(ngx_conf_t cscf->client_header_timeout = NGX_CONF_UNSET_MSEC; cscf->client_header_buffer_size = NGX_CONF_UNSET_SIZE; cscf->restrict_host_names = NGX_CONF_UNSET_UINT; + cscf->optimize_host_names = NGX_CONF_UNSET; cscf->ignore_invalid_headers = NGX_CONF_UNSET; return cscf; @@ -1908,6 +1923,9 @@ ngx_http_core_merge_srv_conf(ngx_conf_t ngx_conf_merge_unsigned_value(conf->restrict_host_names, prev->restrict_host_names, 0); + ngx_conf_merge_value(conf->optimize_host_names, + prev->optimize_host_names, 1); + ngx_conf_merge_value(conf->ignore_invalid_headers, prev->ignore_invalid_headers, 1); @@ -1990,10 +2008,20 @@ ngx_http_core_merge_loc_conf(ngx_conf_t ngx_hash_key_t *type; ngx_hash_init_t types_hash; - ngx_conf_merge_str_value(conf->root, prev->root, "html"); - - if (ngx_conf_full_name(cf->cycle, &conf->root) == NGX_ERROR) { - return NGX_CONF_ERROR; + if (conf->root.data == NULL) { + + conf->root = prev->root; + conf->root_lengths = prev->root_lengths; + conf->root_values = prev->root_values; + + if (prev->root.data == NULL) { + conf->root.len = sizeof("html") - 1; + conf->root.data = (u_char *) "html"; + + if (ngx_conf_full_name(cf->cycle, &conf->root) == NGX_ERROR) { + return NGX_CONF_ERROR; + } + } } if (conf->post_action.data == NULL) { @@ -2417,7 +2445,11 @@ ngx_http_core_root(ngx_conf_t *cf, ngx_c lcf->root.len--; } - n = ngx_http_script_variables_count(&value[1]); + if (ngx_conf_full_name(cf->cycle, &lcf->root) == NGX_ERROR) { + return NGX_CONF_ERROR; + } + + n = ngx_http_script_variables_count(&lcf->root); if (n == 0) { return NGX_CONF_OK; @@ -2426,7 +2458,7 @@ ngx_http_core_root(ngx_conf_t *cf, ngx_c ngx_memzero(&sc, sizeof(ngx_http_script_compile_t)); sc.cf = cf; - sc.source = &value[1]; + sc.source = &lcf->root; sc.lengths = &lcf->root_lengths; sc.values = &lcf->root_values; sc.variables = n; diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h --- a/src/http/ngx_http_core_module.h +++ b/src/http/ngx_http_core_module.h @@ -109,6 +109,7 @@ typedef struct { ngx_uint_t restrict_host_names; + ngx_flag_t optimize_host_names; ngx_flag_t ignore_invalid_headers; } ngx_http_core_srv_conf_t;