exclude some server_name from location processing
Igor Sysoev
is at rambler-co.ru
Tue Jan 16 11:55:18 MSK 2007
On Mon, 15 Jan 2007, Martin Minka wrote:
> nginx is great, but I have small problem when I try to use it.
>
> I would like to do something like:
> # rule 1
> location ~*
> ^.+.(jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|css|doc|xls|exe|pdf|ppt|txt|tar
> |mid|midi|wav|bmp|rtf|js|swf|xml)$ {
>
> # critical part
> if ($server_name ~* ignore-static.com) {
> # skip to the next rule #2
> break;
> }
> ......
> }
>
> # rule 1
> location / {
> # non static files
> ......
> }
>
>
> Any suggestion on how to achieve this ?
Why do you try to mix locations and servers ? In the end you would get
the spaghetti configuration. In general you should route an request
to the specific server using its address/port/name, then you should
route the request using location.
So you should use
server {
server_name one.ignore-static.com two.ignore-static.com;
location / {
# non static files
....
}
}
server {
server_name one.no-ignore-static.com two.no-ignore-static.com;
location / {
# non static files
....
}
location ~*
^.+.(jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|css|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|swf|xml)$ {
....
}
}
Igor Sysoev
http://sysoev.ru/en/
More information about the nginx
mailing list