mirror of https://github.com/nginx/nginx
FastCGI: ensure HTTP_HOST is set to the requested target host.
When using HTTP/2 or prior the CGI/1.1 HTTP_HOST environment variable is set to the requested target host. However with HTTP/3 (or with HTTP/1.1 with the host contained in the request line) this was not happening. The HTTP/2 module uses the ':authority' pseudo-header field to set http_host. It was decided not to do that for HTTP/3. Instead we create a *new* default for http_host which will now use the HOST request header or :authority pseudo-header field. While this is a slight change in behaviour in regards to passing HTTP request header fields, it should be fine in practice as the HTTP host request header and the :authority pseudo-header field should be the same. Also the CGI specification (RFC 3875, 4.1.18) notes The server SHOULD set meta-variables specific to the protocol and scheme for the request. Interpretation of protocol-specific variables depends on the protocol version in SERVER_PROTOCOL. Link: <https://datatracker.ietf.org/doc/html/rfc3875#section-4.1.18> Closes: https://github.com/nginx/nginx/issues/455 Closes: https://github.com/nginx/nginx/issues/912
This commit is contained in:
parent
c70457482c
commit
ac96b275cc
|
|
@ -656,6 +656,13 @@ static ngx_str_t ngx_http_fastcgi_hide_headers[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static ngx_keyval_t ngx_http_fastcgi_headers[] = {
|
||||||
|
{ ngx_string("HTTP_HOST"),
|
||||||
|
ngx_string("$host$is_request_port$request_port") },
|
||||||
|
{ ngx_null_string, ngx_null_string }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#if (NGX_HTTP_CACHE)
|
#if (NGX_HTTP_CACHE)
|
||||||
|
|
||||||
static ngx_keyval_t ngx_http_fastcgi_cache_headers[] = {
|
static ngx_keyval_t ngx_http_fastcgi_cache_headers[] = {
|
||||||
|
|
@ -3276,7 +3283,8 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|
||||||
conf->params_source = prev->params_source;
|
conf->params_source = prev->params_source;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = ngx_http_fastcgi_init_params(cf, conf, &conf->params, NULL);
|
rc = ngx_http_fastcgi_init_params(cf, conf, &conf->params,
|
||||||
|
ngx_http_fastcgi_headers);
|
||||||
if (rc != NGX_OK) {
|
if (rc != NGX_OK) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue