Having issues with nginx / root captures (0.7.53)

Igor Sysoev is at rambler-co.ru
Fri May 1 11:15:35 MSD 2009


On Fri, May 01, 2009 at 10:54:49AM +0400, Igor Sysoev wrote:

> On Thu, Apr 30, 2009 at 11:53:16PM -0700, Michael Shadle wrote:
> 
> > 2009/4/30 Igor Sysoev <is at rambler-co.ru>:
> > 
> > >           server_name  ~...
> > >
> > >           set  $name  $1;
> > >
> > >           root  /....$name;
> > 
> > 
> > server {
> >         listen 80;
> >         index index.php index.html;
> >         server_name ~^foo(.+)\.mike\.bar\.com$;
> >         set $name $1;
> >         root /home/mike/web/foo$name;
> >         include /etc/nginx/defaults.conf;
> > #        include /etc/nginx/development.conf;
> > #       include /etc/nginx/expires.conf;
> >         location ~ \.php$ {
> >                 fastcgi_pass 127.0.0.1:11001;
> >         }
> > #       include /etc/nginx/redfort.conf;
> > }
> > 
> > like that?
> > 
> > you saw development.conf in the last email...
> > 
> > 
> > expires.conf (this causes an issue)
> > 
> > location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
> >         expires max;
> >         access_log off;
> > }
> > 
> > 
> > defaults.conf (this is okay):
> > 
> > location ~ /\.ht {
> >         deny all;
> > }
> > 
> > location = /robots.txt {
> >         log_not_found off;
> > }
> > 
> > location = /favicon.ico {
> >         log_not_found off;
> > }
> > 
> > log_not_found off;
> > 
> > 
> > any ideas on how to get development.conf and defaults.conf to work
> > with the root regex? even with the "set" it still seems to not capture
> > it at the right time.
> 
> It should work, could you create debug log of request ?
> The only "if/rewrite/set" order is important. If "set" is first, then
> it should save the capture in $name.

As it was discovered, the configuration has no "location /".

nginx runs if/set/rewrite scripts twice: once in server context, and
once in locaiton context. Any server has special empty location context.
If you have no "location /" nginx runs "set $name $1" again in location
context. This why the simple (even empty)

   location / { }

is usefull.


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





More information about the nginx mailing list