Skip to content

Conversation

@ac000
Copy link
Member

@ac000 ac000 commented Dec 12, 2025

This set of commits adds a new default value for $http_host for the FastCGI, SCGI & uwsgi modules, which will be based on the HTTP HOST request header or :authority pseudo-header field accordingly.

@ac000 ac000 marked this pull request as ready for review December 12, 2025 16:06
@ac000 ac000 requested a review from pluknet December 12, 2025 16:07
Copy link
Contributor

@pluknet pluknet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The resulting diff looks good.

Please split this change into separate commits, each for its own module.
Although these changes are similar to each other, they do not have nothing that unites them.
Like it was previously done in d8a7c65, 54ce381, 321ff71 series.
This will also allow to set an appropriate commit log prefix:
Proxy: ...
FastCGI: ...

It is important to mention in the commit log that this change alters
the existing behavior to pass CGI parameters from HTTP request header fields.
In particular, that this replaces existing logic to pass HTTP_HOST from $host.
And describe why we alter this.

Something drafted like this might work:

Proxy: improved HTTP_HOST to match request target host.

Previously this always used the request Host header.
.. then describe why this didn't work for HTTP/2 and HTTP/3 ":authority", also for HTTP/1.x absolute URI...

You could also refer in the commit log to the CGI specification
in RFC 3875, section 4.1.18, to support this change, specifically:

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.

(markups are mine)

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: nginx#455
Closes: nginx#912
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>
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants