diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c index bb8964add..bd6ae5f07 100644 --- a/src/http/ngx_http_upstream.c +++ b/src/http/ngx_http_upstream.c @@ -156,6 +156,8 @@ static ngx_int_t ngx_http_upstream_rewrite_set_cookie(ngx_http_request_t *r, ngx_table_elt_t *h, ngx_uint_t offset); static ngx_int_t ngx_http_upstream_copy_allow_ranges(ngx_http_request_t *r, ngx_table_elt_t *h, ngx_uint_t offset); +static ngx_int_t ngx_http_upstream_copy_upgrade(ngx_http_request_t *r, + ngx_table_elt_t *h, ngx_uint_t offset); static ngx_int_t ngx_http_upstream_add_variables(ngx_conf_t *cf); static ngx_int_t ngx_http_upstream_addr_variable(ngx_http_request_t *r, @@ -278,6 +280,10 @@ static ngx_http_upstream_header_t ngx_http_upstream_headers_in[] = { ngx_http_upstream_copy_allow_ranges, offsetof(ngx_http_headers_out_t, accept_ranges), 1 }, + { ngx_string("Upgrade"), + ngx_http_upstream_ignore_header_line, 0, + ngx_http_upstream_copy_upgrade, 0, 0 }, + { ngx_string("Content-Range"), ngx_http_upstream_ignore_header_line, 0, ngx_http_upstream_copy_header_line, @@ -5868,6 +5874,27 @@ ngx_http_upstream_copy_allow_ranges(ngx_http_request_t *r, } +static ngx_int_t +ngx_http_upstream_copy_upgrade(ngx_http_request_t *r, ngx_table_elt_t *h, + ngx_uint_t offset) +{ + ngx_table_elt_t *ho; + + if (r->http_version >= NGX_HTTP_VERSION_20) { + return NGX_OK; + } + + ho = ngx_list_push(&r->headers_out.headers); + if (ho == NULL) { + return NGX_ERROR; + } + + *ho = *h; + + return NGX_OK; +} + + static ngx_int_t ngx_http_upstream_add_variables(ngx_conf_t *cf) {