mirror of
https://github.com/nginx/nginx.git
synced 2025-06-10 19:42:39 +08:00
HTTP/2: use scheme from original request for pushes (closes #1549).
Instead of the connection scheme, use scheme from the original request. This fixes pushes when SSL is terminated by a proxy server in front of nginx.
This commit is contained in:
parent
f11a9cbdd0
commit
fb3a9e28b2
@ -2616,16 +2616,13 @@ ngx_http_v2_push_stream(ngx_http_v2_stream_t *parent, ngx_str_t *path)
|
|||||||
r->method_name = ngx_http_core_get_method;
|
r->method_name = ngx_http_core_get_method;
|
||||||
r->method = NGX_HTTP_GET;
|
r->method = NGX_HTTP_GET;
|
||||||
|
|
||||||
#if (NGX_HTTP_SSL)
|
r->schema.data = ngx_pstrdup(pool, &parent->request->schema);
|
||||||
if (fc->ssl) {
|
if (r->schema.data == NULL) {
|
||||||
ngx_str_set(&r->schema, "https");
|
goto close;
|
||||||
|
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
ngx_str_set(&r->schema, "http");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
r->schema.len = parent->request->schema.len;
|
||||||
|
|
||||||
value.data = ngx_pstrdup(pool, path);
|
value.data = ngx_pstrdup(pool, path);
|
||||||
if (value.data == NULL) {
|
if (value.data == NULL) {
|
||||||
goto close;
|
goto close;
|
||||||
|
@ -944,15 +944,15 @@ ngx_http_v2_push_resource(ngx_http_request_t *r, ngx_str_t *path,
|
|||||||
|
|
||||||
ph = ngx_http_v2_push_headers;
|
ph = ngx_http_v2_push_headers;
|
||||||
|
|
||||||
|
len = ngx_max(r->schema.len, path->len);
|
||||||
|
|
||||||
if (binary[0].len) {
|
if (binary[0].len) {
|
||||||
tmp = ngx_palloc(r->pool, path->len);
|
tmp = ngx_palloc(r->pool, len);
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
len = path->len;
|
|
||||||
|
|
||||||
for (i = 0; i < NGX_HTTP_V2_PUSH_HEADERS; i++) {
|
for (i = 0; i < NGX_HTTP_V2_PUSH_HEADERS; i++) {
|
||||||
h = (ngx_table_elt_t **) ((char *) &r->headers_in + ph[i].offset);
|
h = (ngx_table_elt_t **) ((char *) &r->headers_in + ph[i].offset);
|
||||||
|
|
||||||
@ -994,7 +994,7 @@ ngx_http_v2_push_resource(ngx_http_request_t *r, ngx_str_t *path,
|
|||||||
len = (h2c->table_update ? 1 : 0)
|
len = (h2c->table_update ? 1 : 0)
|
||||||
+ 1
|
+ 1
|
||||||
+ 1 + NGX_HTTP_V2_INT_OCTETS + path->len
|
+ 1 + NGX_HTTP_V2_INT_OCTETS + path->len
|
||||||
+ 1;
|
+ 1 + NGX_HTTP_V2_INT_OCTETS + r->schema.len;
|
||||||
|
|
||||||
for (i = 0; i < NGX_HTTP_V2_PUSH_HEADERS; i++) {
|
for (i = 0; i < NGX_HTTP_V2_PUSH_HEADERS; i++) {
|
||||||
len += binary[i].len;
|
len += binary[i].len;
|
||||||
@ -1025,18 +1025,20 @@ ngx_http_v2_push_resource(ngx_http_request_t *r, ngx_str_t *path,
|
|||||||
*pos++ = ngx_http_v2_inc_indexed(NGX_HTTP_V2_PATH_INDEX);
|
*pos++ = ngx_http_v2_inc_indexed(NGX_HTTP_V2_PATH_INDEX);
|
||||||
pos = ngx_http_v2_write_value(pos, path->data, path->len, tmp);
|
pos = ngx_http_v2_write_value(pos, path->data, path->len, tmp);
|
||||||
|
|
||||||
#if (NGX_HTTP_SSL)
|
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, fc->log, 0,
|
||||||
if (fc->ssl) {
|
"http2 push header: \":scheme: %V\"", &r->schema);
|
||||||
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, fc->log, 0,
|
|
||||||
"http2 push header: \":scheme: https\"");
|
if (r->schema.len == 5 && ngx_strncmp(r->schema.data, "https", 5) == 0) {
|
||||||
*pos++ = ngx_http_v2_indexed(NGX_HTTP_V2_SCHEME_HTTPS_INDEX);
|
*pos++ = ngx_http_v2_indexed(NGX_HTTP_V2_SCHEME_HTTPS_INDEX);
|
||||||
|
|
||||||
} else
|
} else if (r->schema.len == 4
|
||||||
#endif
|
&& ngx_strncmp(r->schema.data, "http", 4) == 0)
|
||||||
{
|
{
|
||||||
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, fc->log, 0,
|
|
||||||
"http2 push header: \":scheme: http\"");
|
|
||||||
*pos++ = ngx_http_v2_indexed(NGX_HTTP_V2_SCHEME_HTTP_INDEX);
|
*pos++ = ngx_http_v2_indexed(NGX_HTTP_V2_SCHEME_HTTP_INDEX);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
*pos++ = ngx_http_v2_inc_indexed(NGX_HTTP_V2_SCHEME_HTTP_INDEX);
|
||||||
|
pos = ngx_http_v2_write_value(pos, r->schema.data, r->schema.len, tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < NGX_HTTP_V2_PUSH_HEADERS; i++) {
|
for (i = 0; i < NGX_HTTP_V2_PUSH_HEADERS; i++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user