diff options
Diffstat (limited to 'src/http')
-rw-r--r-- | src/http/modules/ngx_http_fastcgi_module.c | 2 | ||||
-rw-r--r-- | src/http/modules/ngx_http_proxy_module.c | 20 | ||||
-rw-r--r-- | src/http/modules/perl/nginx.pm | 2 | ||||
-rw-r--r-- | src/http/ngx_http_core_module.c | 11 | ||||
-rw-r--r-- | src/http/ngx_http_request.c | 18 | ||||
-rw-r--r-- | src/http/ngx_http_special_response.c | 2 | ||||
-rw-r--r-- | src/http/ngx_http_upstream.c | 15 |
7 files changed, 38 insertions, 32 deletions
diff --git a/src/http/modules/ngx_http_fastcgi_module.c b/src/http/modules/ngx_http_fastcgi_module.c index 36c59ce4e..5a15fc1e2 100644 --- a/src/http/modules/ngx_http_fastcgi_module.c +++ b/src/http/modules/ngx_http_fastcgi_module.c @@ -553,7 +553,7 @@ ngx_http_fastcgi_create_request(ngx_http_request_t *r) if (len > 65535) { ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, - "fastcgi: the request record is too big"); + "fastcgi request record is too big: %uz", len); return NGX_ERROR; } diff --git a/src/http/modules/ngx_http_proxy_module.c b/src/http/modules/ngx_http_proxy_module.c index 69a12e0fc..5f8b27803 100644 --- a/src/http/modules/ngx_http_proxy_module.c +++ b/src/http/modules/ngx_http_proxy_module.c @@ -675,7 +675,8 @@ ngx_http_proxy_create_request(ngx_http_request_t *r) r->uri.len - loc_len, NGX_ESCAPE_URI); } - len += r->uri.len - loc_len + escape + sizeof("?") - 1 + r->args.len; + len += ctx->vars.uri.len + r->uri.len - loc_len + escape + + sizeof("?") - 1 + r->args.len; } ngx_http_script_flush_no_cacheable_variables(r, plcf->flushes); @@ -2323,7 +2324,7 @@ ngx_http_proxy_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) sc.variables = n; sc.complete_lengths = 1; sc.complete_values = 1; - + if (ngx_http_script_compile(&sc) != NGX_OK) { return NGX_CONF_ERROR; } @@ -2645,8 +2646,6 @@ static ngx_int_t ngx_http_proxy_set_vars(ngx_pool_t *pool, ngx_url_t *u, ngx_http_proxy_vars_t *v) { - u_char *p; - if (!u->unix_socket) { if (u->no_port || u->port == u->default_port) { v->host_header = u->host; @@ -2661,16 +2660,9 @@ ngx_http_proxy_set_vars(ngx_pool_t *pool, ngx_url_t *u, } } else { - p = ngx_palloc(pool, u->host.len + sizeof(":65536") - 1); - if (p == NULL) { - return NGX_ERROR; - } - - v->host_header.len = ngx_sprintf(p, "%V:%d", &u->host, u->port) - p; - v->host_header.data = p; - - v->port.len = v->host_header.len - u->host.len - 1; - v->port.data = p + u->host.len + 1; + v->host_header.len = u->host.len + 1 + u->port_text.len; + v->host_header.data = u->host.data; + v->port = u->port_text; } } else { diff --git a/src/http/modules/perl/nginx.pm b/src/http/modules/perl/nginx.pm index 8932398e9..89e06e563 100644 --- a/src/http/modules/perl/nginx.pm +++ b/src/http/modules/perl/nginx.pm @@ -47,7 +47,7 @@ our @EXPORT = qw( HTTP_INSUFFICIENT_STORAGE ); -our $VERSION = '0.6.20'; +our $VERSION = '0.6.21'; require XSLoader; XSLoader::load('nginx', $VERSION); diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c index da0288dfa..b882f1c2f 100644 --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -69,7 +69,7 @@ static char *ngx_http_core_keepalive(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); static char *ngx_http_core_internal(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); -static char * ngx_http_core_resolver(ngx_conf_t *cf, ngx_command_t *cmd, +static char *ngx_http_core_resolver(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); static char *ngx_http_core_lowat_check(ngx_conf_t *cf, void *post, void *data); @@ -2594,6 +2594,13 @@ ngx_http_core_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) if (conf->resolver == NULL) { conf->resolver = prev->resolver; + + if (conf->resolver == NULL) { + conf->resolver = ngx_resolver_create(NULL, cf->cycle->new_log); + if (conf->resolver == NULL) { + return NGX_OK; + } + } } ngx_conf_merge_path_value(conf->client_body_temp_path, @@ -3393,6 +3400,8 @@ ngx_http_core_resolver(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) value = cf->args->elts; + ngx_memzero(&u, sizeof(ngx_url_t)); + u.host = value[1]; u.port = 53; diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c index e63418306..3d06f964f 100644 --- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c @@ -1154,6 +1154,10 @@ ngx_http_alloc_large_header_buffer(ngx_http_request_t *r, r->args_start = new + (r->args_start - old); } + if (r->http_protocol.data) { + r->http_protocol.data = new + (r->http_protocol.data - old); + } + } else { r->header_name_start = new; r->header_name_end = new + (r->header_name_end - old); @@ -1335,13 +1339,6 @@ ngx_http_process_request_header(ngx_http_request_t *r) return NGX_ERROR; } - if (r->plain_http) { - ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, - "client sent plain HTTP request to HTTPS port"); - ngx_http_finalize_request(r, NGX_HTTP_TO_HTTPS); - return NGX_ERROR; - } - if (r->headers_in.connection_type == NGX_HTTP_CONNECTION_KEEP_ALIVE) { if (r->headers_in.keep_alive) { r->headers_in.keep_alive_n = @@ -1409,6 +1406,13 @@ ngx_http_process_request(ngx_http_request_t *r) c = r->connection; + if (r->plain_http) { + ngx_log_error(NGX_LOG_INFO, c->log, 0, + "client sent plain HTTP request to HTTPS port"); + ngx_http_finalize_request(r, NGX_HTTP_TO_HTTPS); + return; + } + #if (NGX_HTTP_SSL) if (c->ssl) { diff --git a/src/http/ngx_http_special_response.c b/src/http/ngx_http_special_response.c index 20a8fa75d..5671f9bb7 100644 --- a/src/http/ngx_http_special_response.c +++ b/src/http/ngx_http_special_response.c @@ -307,7 +307,7 @@ static ngx_str_t ngx_http_error_pages[] = { ngx_string(ngx_http_error_495_page), /* 495, https certificate error */ ngx_string(ngx_http_error_496_page), /* 496, https no certificate */ ngx_string(ngx_http_error_497_page), /* 497, http to https */ - ngx_string(ngx_http_error_404_page), /* 498, invalid host name */ + ngx_string(ngx_http_error_404_page), /* 498, canceled */ ngx_null_string, /* 499, client has closed connection */ ngx_string(ngx_http_error_500_page), diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c index 7901bb667..e51638b56 100644 --- a/src/http/ngx_http_upstream.c +++ b/src/http/ngx_http_upstream.c @@ -398,13 +398,6 @@ ngx_http_upstream_init(ngx_http_request_t *r) } } - if (clcf->resolver == NULL) { - ngx_log_error(NGX_LOG_ERR, c->log, 0, - "no resolver defined to resolve %V", host); - ngx_http_finalize_request(r, NGX_HTTP_BAD_GATEWAY); - return; - } - temp.name = *host; ctx = ngx_resolve_start(clcf->resolver, &temp); @@ -413,6 +406,14 @@ ngx_http_upstream_init(ngx_http_request_t *r) return; } + if (ctx == NGX_NO_RESOLVER) { + ngx_log_error(NGX_LOG_ERR, c->log, 0, + "no resolver defined to resolve %V", host); + + ngx_http_finalize_request(r, NGX_HTTP_BAD_GATEWAY); + return; + } + ctx->name = *host; ctx->type = NGX_RESOLVE_A; ctx->handler = ngx_http_upstream_resolve_handler; |