diff options
Diffstat (limited to 'src/http')
-rw-r--r-- | src/http/modules/ngx_http_proxy_module.c | 6 | ||||
-rw-r--r-- | src/http/modules/ngx_http_rewrite_module.c | 8 | ||||
-rw-r--r-- | src/http/ngx_http_header_filter_module.c | 53 | ||||
-rw-r--r-- | src/http/ngx_http_script.c | 5 | ||||
-rw-r--r-- | src/http/ngx_http_script.h | 9 |
5 files changed, 66 insertions, 15 deletions
diff --git a/src/http/modules/ngx_http_proxy_module.c b/src/http/modules/ngx_http_proxy_module.c index a24be2444..92dd6cc9c 100644 --- a/src/http/modules/ngx_http_proxy_module.c +++ b/src/http/modules/ngx_http_proxy_module.c @@ -311,8 +311,8 @@ static char ngx_http_proxy_version[] = " HTTP/1.0" CRLF; static ngx_table_elt_t ngx_http_proxy_headers[] = { - { 0, ngx_string("Host"), ngx_string("$proxy_host"), }, - { 0, ngx_string("Connection"), ngx_string("close"), }, + { 0, ngx_string("Host"), ngx_string("$proxy_host") }, + { 0, ngx_string("Connection"), ngx_string("close") }, { 0, ngx_null_string, ngx_null_string } }; @@ -1560,6 +1560,8 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) *s = *h; + src = conf->headers_source->elts; + next: continue; diff --git a/src/http/modules/ngx_http_rewrite_module.c b/src/http/modules/ngx_http_rewrite_module.c index 47ff8c536..da4719b7b 100644 --- a/src/http/modules/ngx_http_rewrite_module.c +++ b/src/http/modules/ngx_http_rewrite_module.c @@ -556,8 +556,7 @@ ngx_http_rewrite(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) regex_end->redirect = regex->redirect; if (last) { - code = ngx_http_script_add_code(lcf->codes, sizeof(uintptr_t), - ®ex); + code = ngx_http_script_add_code(lcf->codes, sizeof(uintptr_t), ®ex); if (code == NULL) { return NGX_CONF_ERROR; } @@ -713,6 +712,11 @@ ngx_http_rewrite_if(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) } + if (lcf->captures < nlcf->captures) { + lcf->captures = nlcf->captures; + } + + if (elts != lcf->codes->elts) { if_code = (ngx_http_script_if_code_t *) ((u_char *) if_code + ((u_char *) lcf->codes->elts - elts)); diff --git a/src/http/ngx_http_header_filter_module.c b/src/http/ngx_http_header_filter_module.c index f3defa07a..a45f2e570 100644 --- a/src/http/ngx_http_header_filter_module.c +++ b/src/http/ngx_http_header_filter_module.c @@ -264,11 +264,26 @@ ngx_http_header_filter(ngx_http_request_t *r) { r->headers_out.location->hash = 0; - len += sizeof("Location: http://") - 1 - + r->server_name.len + r->headers_out.location->value.len + 2; +#if (NGX_HTTP_SSL) + if (r->connection->ssl) { + len += sizeof("Location: https://") - 1 + + r->server_name.len + + r->headers_out.location->value.len + 2; + + if (r->port != 443) { + len += r->port_text->len; + } + + } else +#endif + { + len += sizeof("Location: http://") - 1 + + r->server_name.len + + r->headers_out.location->value.len + 2; - if (r->port != 80) { - len += r->port_text->len; + if (r->port != 80) { + len += r->port_text->len; + } } } @@ -396,13 +411,33 @@ ngx_http_header_filter(ngx_http_request_t *r) && r->headers_out.location->value.data[0] == '/') { p = b->last + sizeof("Location: ") - 1; - b->last = ngx_cpymem(b->last, "Location: http://", - sizeof("Location: http://") - 1); + + b->last = ngx_cpymem(b->last, "Location: http", + sizeof("Location: http") - 1); + +#if (NGX_HTTP_SSL) + if (r->connection->ssl) { + *b->last++ ='s'; + } +#endif + + *b->last++ = ':'; *b->last++ = '/'; *b->last++ = '/'; b->last = ngx_cpymem(b->last, r->server_name.data, r->server_name.len); - if (r->port != 80) { - b->last = ngx_cpymem(b->last, r->port_text->data, - r->port_text->len); + +#if (NGX_HTTP_SSL) + if (r->connection->ssl) { + if (r->port != 443) { + b->last = ngx_cpymem(b->last, r->port_text->data, + r->port_text->len); + } + } else +#endif + { + if (r->port != 80) { + b->last = ngx_cpymem(b->last, r->port_text->data, + r->port_text->len); + } } b->last = ngx_cpymem(b->last, r->headers_out.location->value.data, diff --git a/src/http/ngx_http_script.c b/src/http/ngx_http_script.c index ea1e56b34..89256b355 100644 --- a/src/http/ngx_http_script.c +++ b/src/http/ngx_http_script.c @@ -463,6 +463,9 @@ ngx_http_script_start_args_code(ngx_http_script_engine_t *e) } + +#if (NGX_PCRE) + void ngx_http_script_regex_start_code(ngx_http_script_engine_t *e) { @@ -693,6 +696,8 @@ ngx_http_script_regex_end_code(ngx_http_script_engine_t *e) e->ip += sizeof(ngx_http_script_regex_end_code_t); } +#endif + void ngx_http_script_return_code(ngx_http_script_engine_t *e) diff --git a/src/http/ngx_http_script.h b/src/http/ngx_http_script.h index cf80f22b4..eb6f17ea9 100644 --- a/src/http/ngx_http_script.h +++ b/src/http/ngx_http_script.h @@ -79,6 +79,8 @@ typedef struct { } ngx_http_script_copy_capture_code_t; +#if (NGX_PCRE) + typedef struct { ngx_http_script_code_pt code; ngx_regex_t *regex; @@ -114,6 +116,8 @@ typedef struct { uintptr_t redirect:1; } ngx_http_script_regex_end_code_t; +#endif + typedef struct { ngx_http_script_code_pt code; @@ -156,10 +160,11 @@ size_t ngx_http_script_copy_var_len_code(ngx_http_script_engine_t *e); void ngx_http_script_copy_var_code(ngx_http_script_engine_t *e); size_t ngx_http_script_copy_capture_len_code(ngx_http_script_engine_t *e); void ngx_http_script_copy_capture_code(ngx_http_script_engine_t *e); +void ngx_http_script_start_args_code(ngx_http_script_engine_t *e); +#if (NGX_PCRE) void ngx_http_script_regex_start_code(ngx_http_script_engine_t *e); void ngx_http_script_regex_end_code(ngx_http_script_engine_t *e); -void ngx_http_script_copy_capture_code(ngx_http_script_engine_t *e); -void ngx_http_script_start_args_code(ngx_http_script_engine_t *e); +#endif void ngx_http_script_return_code(ngx_http_script_engine_t *e); void ngx_http_script_if_code(ngx_http_script_engine_t *e); void ngx_http_script_complex_value_code(ngx_http_script_engine_t *e); |