nginx-0.7.31

Igor Sysoev is at rambler-co.ru
Tue Jan 20 14:14:57 MSK 2009


On Mon, Jan 19, 2009 at 08:44:48PM +0300, Igor Sysoev wrote:

> On Mon, Jan 19, 2009 at 04:47:33PM +0000, cynix wrote:
> 
> > Igor Sysoev <is at ...> writes:
> > 
> > > 
> > > Changes with nginx 0.7.31                                        19 Jan 2009
> > > 
> > >     *) Change: now the "try_files" directive tests files only and ignores 
> > >        directories.
> > > 
> > 
> > This seems to cause problems with index.php inside directories. For example:
> > 
> >  index index.php;
> >  location / {
> >   try_files $uri @php;
> >  }
> >  location @php {
> >   fastcgi_pass ...;
> >   fastcgi_param SCRIPT_FILENAME $document_root/index.php;
> >  }
> >  location ~ \.php$ {
> >   fastcgi_pass ...;
> >   fastcgi_param SCRIPT_FILENAME $document_root$uri;
> >  }
> > 
> > With 0.7.30 if you request http://example.com/test/ ,
> > $document_root/test/index.php is served. However with 0.7.31,
> > $document_root/index.php is served.
> > 
> > And if you do this:
> > 
> >  try_files $uri $uri/index.php @php;
> > 
> > then nginx will serve index.php as a static file, without passing it to FastCGI.
> > I know this is the intended behavior, as internal rewrite is only issued for the
> > last parameter of try_files. So how should we let try_files detect index.php
> > inside a directory if directories are ignored?
> 
> The change has been apperaed due to Mongrel-type configuration:
> 
> location / {
>     try_files      /system/maintenance.html
>                    $uri  $uri/index.html  $uri.html
>                    @mongrel;
> }
> 
> location @mogrel {
>     proxy_pass     http://mongrel;
> }
> 
> when "/" exists, but /index.html is not exist, then request was handled
> locally and return 403.
> 
> I will look how to resolve the issue.

I think we can say explicitly that we want to test directory existance
using trailing slash:

   try_files $uri  $uri/  @php;


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





More information about the nginx mailing list