Welcome! Log In Create A New Profile

Advanced

Re: Can I proxy_pass to a variable?

May 10, 2010 04:58AM
On Mon, May 10, 2010 at 04:29:46PM +0800, 任晓磊 wrote:

> On Mon, May 10, 2010 at 2:07 PM, Igor Sysoev <igor@sysoev.ru> wrote:
> > You have to write:
> >
> >     proxy_pass http://$http_host$request_uri;
> >
> > Since 0.8.25 and 0.7.65, you may write:
> >
> >     proxy_pass http://$http_host;
>
> But, why didn't I need to specify $request_uri when proxy_pass to a
> literal value?

For historical reasons.
There are two ways to map URI to a resource: root and alias:

location /dir1/ {
root /path/to;
}

location /dir2/ {
alias /path/to/dir3/;
}

The variables support has appeared eventually:

location / {
root /path/$host;
}

location ~ ^/~(?<user>[^/]+)(?<path>.*)$ {
alias /homes/$user/$path;
}

In proxy_pass the root way is:

location /dir1/ {
proxy_pass http://host;
}

The alias way is:

location /dir2/ {
proxy_pass http://host/dir3/;
}

The proxy_pass variables support has appeared to support proxying to a full
URL only as in static alias. Then the root way has been added.


--
Igor Sysoev
http://sysoev.ru/en/

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Can I proxy_pass to a variable?

任晓磊 May 09, 2010 11:58PM

Re: Can I proxy_pass to a variable?

Boris Dolgov May 10, 2010 02:06AM

Re: Can I proxy_pass to a variable?

Igor Sysoev May 10, 2010 02:10AM

Re: Can I proxy_pass to a variable?

任晓磊 May 10, 2010 04:34AM

Re: Can I proxy_pass to a variable?

Igor Sysoev May 10, 2010 04:58AM

Re: Can I proxy_pass to a variable?

任晓磊 May 10, 2010 05:04AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 178
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready