Regular expressions in server_name: pattern length

Igor Sysoev igor at sysoev.ru
Wed Dec 9 15:49:48 MSK 2009


On Wed, Dec 09, 2009 at 10:21:11AM +0000, Phillip Oldham wrote:

> Igor Sysoev wrote:
> > It's possible:
> >
> > server {
> >      server_name ~^([a-z]{2,3})?\d{3,6}\.mysite\.org$;
> > }
> >
> > server {
> >      server_name ~^(\w+)\.mysite\.org$;
> > }
> >   
> Is this with the latest devel, or stable?

regex as a main server_name supported since 0.6.25.
server_name captures can be used since 0.7.40.
Named server_name captures can be used since 0.8.25.

> > You may also control the order of sites.
> >   
> Can you give an example on how to do this?

server_name's regular expressions are tested in order listed in
configuration file. You should list first more specific servers.


-- 
Igor Sysoev
http://sysoev.ru/en/



More information about the nginx mailing list