Score:1

What exactly is the nginx request_uri?

pk flag

I'm trying to understand the $request_uri variable in nginx configuration. The documentation says

full original request URI (with arguments)

To me that seems to be totally unambiguous - it should be the entire requested URI, including the host and protocol. But in actual usage, it seems to only include the path & query arguments. Is there any authoritative source that says exactly what nginx considers to be a request_uri? I can't find any further references in the documentation, and I tried to get it out of the source code, but there are no comments and it's hard to understand the overall structure.

Score:3
jp flag

The Request-URI does not refer to the RFC 3986 URI, but is a term from RFC 2616, 5.1.2 HTTP/1.1 draft standard from 1999.

The Request-URI in RFC 2616 could have been any of:

Request-URI = "*" | absoluteURI | abs_path | authority

Here, the absoluteURI is equivalent with the RFC 3986 URI, and mainly used in HTTP proxys. Søren Løvborg explains in an answer on Stack Overflow why it is not necessary to have the full URI in this context:

In normal HTTP requests, the URL scheme and host have already been handled by the time the request is sent (and the URL fragment does not exist at the HTTP protocol level at all), meaning the Request-URI is a path-absolute-URL string, possibly followed by ? and a URL-query string.

Request-URI seems to be replaced with the (more unambiguous) term Request Target in RFC 7230, 3.1.1 proposed standard from 2014, where a Request Line...

begins with a method token, followed by a single space (SP), the request-target, another single space (SP), the protocol version, and ends with CRLF.

request-line = method SP request-target SP HTTP-version CRLF

The Request Target term is also used in the RFC 9110, 7.1 of the Internet Standard (June 2022); URI References are defined in RFC 9110, 4.1.

preferred_anon avatar
pk flag
Thanks for the references! Is it safe to assume that "Request-URI" always refers to the path, args, etc. or is it genuinely ambiguous? As for the justification, that does make sense.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.