Skip to content

Commit 1182822

Browse files
committed
Uwsgi: 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>
1 parent 830599c commit 1182822

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/http/modules/ngx_http_uwsgi_module.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,13 @@ static ngx_str_t ngx_http_uwsgi_hide_headers[] = {
629629
};
630630

631631

632+
static ngx_keyval_t ngx_http_uwsgi_headers[] = {
633+
{ ngx_string("HTTP_HOST"),
634+
ngx_string("$host$is_request_port$request_port") },
635+
{ ngx_null_string, ngx_null_string }
636+
};
637+
638+
632639
#if (NGX_HTTP_CACHE)
633640

634641
static ngx_keyval_t ngx_http_uwsgi_cache_headers[] = {
@@ -1995,7 +2002,8 @@ ngx_http_uwsgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
19952002
conf->params_source = prev->params_source;
19962003
}
19972004

1998-
rc = ngx_http_uwsgi_init_params(cf, conf, &conf->params, NULL);
2005+
rc = ngx_http_uwsgi_init_params(cf, conf, &conf->params,
2006+
ngx_http_uwsgi_headers);
19992007
if (rc != NGX_OK) {
20002008
return NGX_CONF_ERROR;
20012009
}

0 commit comments

Comments
 (0)