Minimal configuration

Francis Daly francis at daoine.org
Mon Feb 17 08:42:48 UTC 2014


On Mon, Feb 17, 2014 at 12:42:28AM +0100, B.R. wrote:

Hi there,

> If I may, there is still a little something bothering me:
> The condition required for a loop to be created is that $uri (= /) doesn't
> match any file, thus redirecting and trying again.
> Why on Earth does '/' as error handler matches anything then?

I may be being confused by terminology here. Where does "error handler"
come in to it?

try_files takes multiple arguments -- at least one "file", plus one "uri".

If it gets that far, there is an internal redirect to the final argument.

The other arguments are tried in turn, by prepending $document_root and
seeing if there is a file or directory with that name available. (If
the argument ends in /, it looks for a directory; otherwise it looks
for a file.)

The first matching file-or-directory is processed in the current context.

If that isn't clear, all I can suggest is that you read the source
and/or test, and write the documentation that would make it clear to you,
and submit that to the official docs.

> Stated otherwise, why does '/' as error handler uses index files to find
> something while '/' contained in $uri doesn't find anything? Isn't the
> 'index' directive used there?

try_files doesn't use "index".

try_files can see that (if the current "file" argument ends in a /)
the directory exists, and that therefore this request should be served
by this "file" in this context. After that, "index" can apply and you get
index.html or 403 or whatever else is appropriate.

	f
-- 
Francis Daly        francis at daoine.org



More information about the nginx mailing list