redirect subdomain to internal location

chris.percol nginx-forum at nginx.us
Wed May 25 22:14:52 MSD 2011


António P. P. Almeida Wrote:
-------------------------------------------------------
> On 25 Mai 2011 15h26 WEST, nginx-forum at nginx.us
> wrote:
> 
> > Thanks guys,
> >
> > I get that now, in my newness to nginx I was
> overcomplicating
> > things. My server_name is now doing what I had
> hoped to achieve.
> >
> > If you can bear with me for one more question,
> how do I get the
> > 'client' out of
> domain.com/client/more/stuff.htm? I want to use
> the
> > 'client' part of the uri to search a redis
> key/value pair.
> >
> > I had success with this code for query strings
> but couldn't work out
> > how to get the first part of the uri to be my
> key?
> >
> > location / {
> > eval_escalate on;
> > eval $res {
> > set_unescape_uri $key $arg_key;
> > redis2_query get $key;
> > redis2_pass 127.0.0.1:6379;
> > }
> > set_by_lua $path "return
> > require('redis.parser').parse_reply(ngx.arg[1])"
> $res;
> > proxy_pass http://app_cluster_1/$path;
> > proxy_redirect off;
> > }
> 
> If I'm understanding correctly what you want to
> do, you'll need a
> location with a regex that captures that URI
> component. E.g.:
> 
> location ~ /(?<clientkey>[^/]*)/ {

Appa,

Thanks again!

My issue is that I don't know the value of clientkey, it could be
several hundred possibilities.

Is there a way to extract the unknown clientkey from
/clientkey/some/more.htm?

Many thanks,

Chris

>   (...)
>   set_unescape_uri $key $clientkey;
>   (...)
> }
> 
> This will match all URIs of the form 
> /whatever/anything
> 
> Forgot the little detail of the ~ for a regex
> based location. Now it
> seems correct.
> 
> --- appa
> 
> 
> 
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://nginx.org/mailman/listinfo/nginx

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,200694,200846#msg-200846




More information about the nginx mailing list