Welcome! Log In Create A New Profile

Advanced

Re: Regarding using of nginx http load balancer

Pankaj Kaushik
August 05, 2014 07:12AM
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@nginx.com> wrote:

>
> On 05 Aug 2014, at 12:58, Pankaj Kaushik <dev.panky2014@gmail.com> wrote:
>
> > Hey Piotr,
> >
> >
> >
> > On Tue, Aug 5, 2014 at 2:21 PM, Piotr Sikora <piotr@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@nginx.org
> > http://mailman.nginx.org/mailman/listinfo/nginx-devel
>
> _______________________________________________
> nginx-devel mailing list
> nginx-devel@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-devel
>
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Regarding using of nginx http load balancer

Pankaj Kaushik 640 August 05, 2014 04:48AM

Re: Regarding using of nginx http load balancer

Piotr Sikora 261 August 05, 2014 04:52AM

Re: Regarding using of nginx http load balancer

Pankaj Kaushik 238 August 05, 2014 05:00AM

Re: Regarding using of nginx http load balancer

Roman Arutyunyan 261 August 05, 2014 05:38AM

Re: Regarding using of nginx http load balancer

Pankaj Kaushik 307 August 05, 2014 07:12AM

Re: Regarding using of nginx http load balancer

Roman Arutyunyan 424 August 05, 2014 07:56AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 98
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