Understanding location blocks and try files

Valentin V. Bartenev vbart at nginx.com
Wed Jan 22 21:30:02 UTC 2014

On Wednesday 22 January 2014 21:07:13 Jonathan Matthews wrote:
> ... and its this last step which isn't working as expected. I don't
> quite have the explanation or docs to hand to say why this won't work,
> but this SO page seems to have an interestingly un-up-voted answer at
> the bottom of the page:
> http://stackoverflow.com/questions/13138318/nginx-try-files-outside-location
> "You are probably under the delusion that try_files on server level
> must work for every request. Not at all. Quite the contrary, it works
> only for requests that match no location blocks."
> I'd be really interested to get confirmation that that statement is
> unequivocally true!

Well, actually I wrote this answer.  So, I can confirm. =)

You may also find confirmations by Igor and Maxim by searching
through the mailing list.

There is a bit of history:

Changes with nginx 0.7.44                                        23 Mar 2009

    *) Feature: the "try_files" directive is now allowed on the server block

but, personally I think it was a bad decision that eventually resulted to a 
lot of confusion around.

 wbr, Valentin V. Bartenev

More information about the nginx mailing list