diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/http/ngx_http_core_module.c | 1 | ||||
-rw-r--r-- | src/http/ngx_http_header_filter_module.c | 4 | ||||
-rw-r--r-- | src/http/ngx_http_request.c | 22 | ||||
-rw-r--r-- | src/http/ngx_http_request.h | 1 | ||||
-rw-r--r-- | src/http/ngx_http_variables.c | 31 |
5 files changed, 39 insertions, 20 deletions
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c index 5e2f2d3d5..27e723a5d 100644 --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -1780,7 +1780,6 @@ ngx_http_subrequest(ngx_http_request_t *r, sr->in_addr = r->in_addr; sr->port = r->port; sr->port_text = r->port_text; - sr->server_name = r->server_name; sr->variables = r->variables; diff --git a/src/http/ngx_http_header_filter_module.c b/src/http/ngx_http_header_filter_module.c index 79e4b3bc7..9cdac6126 100644 --- a/src/http/ngx_http_header_filter_module.c +++ b/src/http/ngx_http_header_filter_module.c @@ -160,6 +160,7 @@ ngx_http_header_filter(ngx_http_request_t *r) ngx_list_part_t *part; ngx_table_elt_t *header; ngx_http_core_loc_conf_t *clcf; + ngx_http_core_srv_conf_t *cscf; /* AF_INET only */ u_char addr[INET_ADDRSTRLEN]; @@ -282,7 +283,8 @@ ngx_http_header_filter(ngx_http_request_t *r) r->headers_out.location->hash = 0; if (clcf->server_name_in_redirect) { - host = r->server_name; + cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); + host = cscf->server_name; } else if (r->headers_in.host) { host.len = r->headers_in.host_name_len; diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c index 8a8b5ac97..e3cbcddf7 100644 --- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c @@ -340,8 +340,6 @@ ngx_http_init_request(ngx_event_t *rev) r->srv_conf = cscf->ctx->srv_conf; r->loc_conf = cscf->ctx->loc_conf; - r->server_name = cscf->server_name; - rev->handler = ngx_http_process_request_line; #if (NGX_HTTP_SSL) @@ -1512,9 +1510,6 @@ ngx_http_find_virtual_server(ngx_http_request_t *r, u_char *host, size_t len, found: - r->server_name.len = len; - r->server_name.data = host; - r->srv_conf = cscf->ctx->srv_conf; r->loc_conf = cscf->ctx->loc_conf; @@ -2605,15 +2600,16 @@ static u_char * ngx_http_log_error_handler(ngx_http_request_t *r, ngx_http_request_t *sr, u_char *buf, size_t len) { - char *uri_separator; - u_char *p; - ngx_http_upstream_t *u; + char *uri_separator; + u_char *p; + ngx_http_upstream_t *u; + ngx_http_core_srv_conf_t *cscf; - if (r->server_name.data) { - p = ngx_snprintf(buf, len, ", server: %V", &r->server_name); - len -= p - buf; - buf = p; - } + cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); + + p = ngx_snprintf(buf, len, ", server: %V", &cscf->server_name); + len -= p - buf; + buf = p; if (r->request_line.data == NULL && r->request_start) { for (p = r->request_start; p < r->header_in->last; p++) { diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h index 1ff140aed..db1292b8c 100644 --- a/src/http/ngx_http_request.h +++ b/src/http/ngx_http_request.h @@ -373,7 +373,6 @@ struct ngx_http_request_s { uint32_t in_addr; ngx_uint_t port; ngx_str_t *port_text; /* ":80" */ - ngx_str_t server_name; ngx_http_virtual_names_t *virtual_names; ngx_int_t phase_handler; diff --git a/src/http/ngx_http_variables.c b/src/http/ngx_http_variables.c index 971f70522..df00675eb 100644 --- a/src/http/ngx_http_variables.c +++ b/src/http/ngx_http_variables.c @@ -47,6 +47,8 @@ static ngx_int_t ngx_http_variable_document_root(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data); static ngx_int_t ngx_http_variable_request_filename(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data); +static ngx_int_t ngx_http_variable_server_name(ngx_http_request_t *r, + ngx_http_variable_value_t *v, uintptr_t data); static ngx_int_t ngx_http_variable_request_method(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data); static ngx_int_t ngx_http_variable_remote_user(ngx_http_request_t *r, @@ -172,8 +174,7 @@ static ngx_http_variable_t ngx_http_core_variables[] = { ngx_http_variable_request_filename, 0, NGX_HTTP_VAR_NOCACHEABLE, 0 }, - { ngx_string("server_name"), NULL, ngx_http_variable_request, - offsetof(ngx_http_request_t, server_name), 0, 0 }, + { ngx_string("server_name"), NULL, ngx_http_variable_server_name, 0, 0, 0 }, { ngx_string("request_method"), NULL, ngx_http_variable_request_method, 0, 0, 0 }, @@ -709,6 +710,8 @@ static ngx_int_t ngx_http_variable_host(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data) { + ngx_http_core_srv_conf_t *cscf; + if (r->host_start == NULL) { if (r->headers_in.host) { @@ -716,8 +719,10 @@ ngx_http_variable_host(ngx_http_request_t *r, ngx_http_variable_value_t *v, v->data = r->headers_in.host->value.data; } else { - v->len = r->server_name.len; - v->data = r->server_name.data; + cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); + + v->len = cscf->server_name.len; + v->data = cscf->server_name.data; } } else if (r->host_end) { @@ -957,6 +962,24 @@ ngx_http_variable_request_filename(ngx_http_request_t *r, static ngx_int_t +ngx_http_variable_server_name(ngx_http_request_t *r, + ngx_http_variable_value_t *v, uintptr_t data) +{ + ngx_http_core_srv_conf_t *cscf; + + cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); + + v->len = cscf->server_name.len; + v->valid = 1; + v->no_cacheable = 0; + v->not_found = 0; + v->data = cscf->server_name.data; + + return NGX_OK; +} + + +static ngx_int_t ngx_http_variable_request_method(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data) { |