Welcome! Log In Create A New Profile

Advanced

Beginner question:Nginx request_uri meaning ?

Posted by Bike dernikov1 
Bike dernikov1
Beginner question:Nginx request_uri meaning ?
January 11, 2017 05:20PM
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.
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Maxim Dounin
Re: Beginner question:Nginx request_uri meaning ?
January 11, 2017 06:30PM
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/
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Bike dernikov1
Re: Beginner question:Nginx request_uri meaning ?
January 12, 2017 09:50AM
Hi,
Thanks for answer and detail explanation.
So to conclude and confirm that i undestand completly.
If client request

http://www.example.com/index.html

return 301 $scheme://example1.com$request_uri;

mean: return 301 http://example1.com/index.html.

Thanks again for big help. I wold never found explanation myself.







On Wed, Jan 11, 2017 at 6:28 PM, Maxim Dounin <[email protected]> wrote:

> 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/
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Maxim Dounin
Re: Beginner question:Nginx request_uri meaning ?
January 12, 2017 02:50PM
Hello!

On Thu, Jan 12, 2017 at 09:43:35AM +0100, Bike dernikov1 wrote:

> Hi,
> Thanks for answer and detail explanation.
> So to conclude and confirm that i undestand completly.
> If client request
>
> http://www.example.com/index.html
>
> return 301 $scheme://example1.com$request_uri;
>
> mean: return 301 http://example1.com/index.html.

Yes, $request_uri would be "/index.html" in this case.

--
Maxim Dounin
http://nginx.org/
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
tokers
Re: Beginner question:Nginx request_uri meaning ?
January 23, 2017 10:20AM
$request_uri is a built-in variable of Nginx, which meaning is the pure uri
in HTTP request line without any process.

For instance, if the HTTP request line is "GET /path/to//a.jpg HTTP/1.1",
the $request_uri is "/path/to//a.jpg". But the $uri will be "/path/to/a.jpg"
if merge_slashes is enable.

if the HTTP request line is "GET /path%2Fto/a.jpg HTTP1/1.", the
$request_uri is "/path%2Fto/a.jpg". But the $uri will be "/path/to/a.jpg".

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,271937,272108#msg-272108

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Sorry, only registered users may post in this forum.

Click here to login