Regarding using of nginx http load balancer
Pankaj Kaushik
dev.panky2014 at gmail.com
Tue Aug 5 11:11:08 UTC 2014
Hey Roman,
I do not actually get the idea how to use map in below scenario.
Suppose i have two form of uri as mentioned below:-
URI 1 : http://abc.10.23.32.22:2000/testFile
URI 2 : http://10.20.32.23:2000/def/testFile
So i want to fetch out following substring from above mentioned URI's as a
key :-
Key 1 : abc
Key 2 : def
Now i want to use them in upstream configuration as :-
http {
upstream myapp1 {
hash Key1 consistent;
server 10.23.22.34:8080;
}
server {
listen 80;
location / {
proxy_pass http://myapp1;
}
}
}
How can i do this ?
Thanks,
Panky
On Tue, Aug 5, 2014 at 3:07 PM, Roman Arutyunyan <arut at nginx.com> wrote:
>
> On 05 Aug 2014, at 12:58, Pankaj Kaushik <dev.panky2014 at gmail.com> wrote:
>
> > Hey Piotr,
> >
> >
> >
> > On Tue, Aug 5, 2014 at 2:21 PM, Piotr Sikora <piotr at cloudflare.com>
> wrote:
> >
> > What's wrong with "hash" [1]?
> >
> > [1] http://nginx.org/en/docs/http/ngx_http_upstream_module.html#hash
> >
> >
> >
> > As mentioned in the syntax at above link:-
> >
> > Syntax: hash key [consistent];
> > Default: —
> > Context: upstream
> >
> >
> > In my scenario i have to fetch key out of uri and then need to hash that
> to identify the backend server.
> >
> > Basically i need to fetch the key out of uri during run time.
> >
> > Can you please help in knowing how can i do that?
> >
>
> You can use $arg_XXX variables to access arguments passed in uri.
> Or you can use “map" directive to fetch any part of $uri directly
>
> http://nginx.org/ru/docs/http/ngx_http_map_module.html
>
> > Thanks,
> > Panky
> >
> > _______________________________________________
> > nginx-devel mailing list
> > nginx-devel at nginx.org
> > http://mailman.nginx.org/mailman/listinfo/nginx-devel
>
> _______________________________________________
> nginx-devel mailing list
> nginx-devel at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20140805/900560ab/attachment-0001.html>
More information about the nginx-devel
mailing list