nginx-0.7.31

Igor Sysoev is at rambler-co.ru
Mon Jan 19 20:44:48 MSK 2009


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.

One possible solution:

  location / {
      try_files $uri @php;
  }

  location @php {
      fastcgi_pass ...;
      fastcgi_param SCRIPT_FILENAME $document_root/index.php;
  }

  location ~ (/|\.php)$ {
      fastcgi_pass ...;
      fastcgi_index index.php;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  }


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





More information about the nginx mailing list