Beginner question:Nginx request_uri meaning ?
Maxim Dounin
mdounin at mdounin.ru
Wed Jan 11 17:28:47 UTC 2017
Hello!
On Wed, Jan 11, 2017 at 05:18:26PM +0100, Bike dernikov1 wrote:
> Hi, i have "simple" question, need simple explanation. It's driving me
> nuts.
>
> In nginx configuration what is meaning of $request_uri in line?
>
> *********************************************************
> return 301 $scheme://example.com1$request_uri;
> ***********************************************************
> In documentation write: $request_uri is full request URI.
> I will try to describe my doubth.
>
> Simple request URL: http://www.example.com/index.html
>
> Full request URI is the same: http://example.com/index.html
>
> $request_uri=http://example.com/index.html.
>
> As i understand then line:
>
> return 301 $scheme://example1.com$request_uri;
>
> must return:
>
> http://example1.comhttp://example.com/index.html.
>
> But that cannot be correct.
>
> So what mean var $request_uri ? Is defined wrong in documentation. (or URI
> is not what i described ?) or it mean something different, or it mean
> something different in combination with return ??
> Thanks for help.
The term "request URI" as used in the nginx documentation in many
places, as well as in various variables, dates back to the
original and most common HTTP meaning - the URI form as used
identify a resource on a server.
Quoting https://tools.ietf.org/html/rfc1945#section-5.1.2:
The most common form of Request-URI is that used to identify a
resource on an origin server or gateway. In this case, only the
absolute path of the URI is transmitted (see Section 3.2.1,
abs_path). For example, a client wishing to retrieve the resource
above directly from the origin server would create a TCP connection
to port 80 of the host "www.w3.org" and send the line:
GET /pub/WWW/TheProject.html HTTP/1.0
followed by the remainder of the Full-Request. Note that the absolute
path cannot be empty; if none is present in the original URI, it must
be given as "/" (the server root).
At the HTTP/1.0 time this was the only allowed form in requests to
origin servers (absolute form was only allowed in requests to a
proxy).
With HTTP/1.1 absolute form can be also used in normal
requests, but it's not something actually used in practice, and
also not something various configurations and software can cope
with. So even if a request uses the absolute form of the request
URI, nginx provides $request_uri as if it was given in the
abs_path form.
--
Maxim Dounin
http://nginx.org/
More information about the nginx
mailing list