How to use fastcgi_index?

Igor Sysoev is at rambler-co.ru
Thu Nov 6 16:03:34 MSK 2008


On Thu, Nov 06, 2008 at 12:32:03PM +0100, Michael Schmarck wrote:

> Hello again!
> 
> 2008/11/6 Igor Sysoev <is at rambler-co.ru>
> 
> > The index directive looks up local filesystem for index files,
> > so in following configuration
> >
> >     location / {
> >         root   /data/www;
> >         index  index.php;
> >     }
> >
> >     location ~ \.php$ {
> >         fastcgi ...
> >     }
> >
> > the index sees /data/www/index.php and does internal redirect to /index.php,
> > so the request goes to "location ~ \.php$" and is passed to fastcgi.
> >
> > However, if fastcgi server is remote one, and nginx has no access to its
> > filesystem, then index has no idea about remote index files. The fastcgi_index
> > should help here: it simply adds its value to any /dir/, i.e. it maps
> > /dir/ to /dir/index.php.
> >
> >     location ~ (\.php|/)$ {
> >         fastcgi_index  index.php;
> >         fastcgi_param  SCRIPT_FILENAME  /data/www$fastcgi_script_name;
> >     }
> 
> Let me see, if I got this right - fastcgi_index is, in my setup,
> where nginx and the fastcgi server share filesystems, in such
> a setup fastcgi_index doesn't do anything at all and can be
> omitted.
> 
> Correct?

Yes, fastcgi_index inside "location ~ \.php$" does not anything because 
he location matches .php only files, but not ".../" requests.

Also, note that "index" can test several index files (PHP, HTML, etc) on
local filesystem, but "fastcgi_index" can add the single index file only
in $fastcgi_script_name variable to pass it to fastcgi server.


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





More information about the nginx mailing list