Forum: NGINX One last question about root captures/etc.

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F5a6ed477b109fe6acc11a5a8f87e7e8?d=identicon&s=25 Michael Shadle (Guest)
on 2009-05-04 10:24
(Received via mailing list)
The first one always gets matched. Is there a way to make nginx use
the one that matches the best?

i.e.

foo123.mike.bar.com should go to #2
foo.mike.bar.com should go to #2
blah.mike.bar.com should go to #1

etc.

i've tried in opposite order but it seems that it always sides with
the more generic one, which does make sense i suppose but perhaps
there is a way around it?

thanks.


server {
       listen 80;
       index index.php index.html;
       server_name ~^(.*?)\.mike\.bar\.com$;
       set $name $1;
       root /home/mike/web/$name;
       location / { }
}


server {
        listen 80;
        index index.php index.html;
        server_name ~^foo(.*?)\.mike\.bar\.com$;
        set $name $1;
        root /home/mike/web/foo$name;
       location / { }
}
5640e332954fc0006aea97a155ce0afd?d=identicon&s=25 Igor Sysoev (Guest)
on 2009-05-04 10:31
(Received via mailing list)
On Mon, May 04, 2009 at 01:13:58AM -0700, Michael Shadle wrote:

>
>        server_name ~^(.*?)\.mike\.bar\.com$;
>         set $name $1;
>         root /home/mike/web/foo$name;
>        location / { }
> }

Regexs in server names are run in order of their appearence.
6d4a6e9574c15d11480db6d7e5eb2750?d=identicon&s=25 Delta Yeh (Guest)
on 2009-05-04 10:38
(Received via mailing list)
How about location block? Merged or  in order of their appearence

i.e.

  location /aa {
     conf1
  }
  location /bb {
    conf2
  }
  location /aa {
    conf3
  }


if request uri is /aa, what's the conf is ?

2009/5/4 Igor Sysoev <is@rambler-co.ru>
F5a6ed477b109fe6acc11a5a8f87e7e8?d=identicon&s=25 Michael Shadle (Guest)
on 2009-05-04 10:40
(Received via mailing list)
2009/5/4 Igor Sysoev <is@rambler-co.ru>:

> Regexs in server names are run in order of their appearence.

are you sure? i tried different order and it still matched the same
default one.
F5a6ed477b109fe6acc11a5a8f87e7e8?d=identicon&s=25 Michael Shadle (Guest)
on 2009-05-04 10:40
(Received via mailing list)
i am working on hostname based regexs, not location based ones...
F5a6ed477b109fe6acc11a5a8f87e7e8?d=identicon&s=25 Michael Shadle (Guest)
on 2009-05-04 10:43
(Received via mailing list)
nevermind.

i think this might be working now. maybe i had something else going on.

ignore me :)
5640e332954fc0006aea97a155ce0afd?d=identicon&s=25 Igor Sysoev (Guest)
on 2009-05-04 12:03
(Received via mailing list)
On Mon, May 04, 2009 at 04:29:41PM +0800, Delta Yeh wrote:

>   location /aa {
>     conf3
>   }
>
>
> if request uri is /aa, what's the conf is ?

nginx 0.7 exits with error about duplicate location.
7ce625ba598c1198061bdf1b1a1353a5?d=identicon&s=25 dennis cao (Guest)
on 2009-05-04 13:56
(Received via mailing list)
dear all:

        i want to limit the total bandwidth  outgoing

       do nginx support this module ?



i use the iptables+tc to do this before
This topic is locked and can not be replied to.