Can I proxy_pass to a variable?
Igor Sysoev
igor at sysoev.ru
Mon May 10 12:52:00 MSD 2010
On Mon, May 10, 2010 at 04:29:46PM +0800, 任晓磊 wrote:
> On Mon, May 10, 2010 at 2:07 PM, Igor Sysoev <igor at 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/
More information about the nginx
mailing list