From f861f2ff0108381b5fc01d303831340679fd174a Mon Sep 17 00:00:00 2001 From: AD7six Date: Thu, 23 Oct 2014 15:21:31 +0000 Subject: [PATCH] mention try_files in server context gotcha --- doc/how-nginx-works.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/doc/how-nginx-works.md b/doc/how-nginx-works.md index 7de9503..6057d50 100644 --- a/doc/how-nginx-works.md +++ b/doc/how-nginx-works.md @@ -41,3 +41,26 @@ will be included: There are some significant concequences to this behavior such as it _not_ being possible to build configuration files from small, overlapping, location blocks. + +## try_files in the server_context does not always apply + +Consider the following server block: + + server { + listen 80; + server_name example.com; + root /var/www/example.com; + + try_files $uri $uri/ /fallback.html; + + location ~ ^/somefolder { + ... + } + + } + +It might be expected that a request for `http://example.com/somefolder/doesnt-exist` +would result in the contents of `/fallback.html` - but this is not the case. the +`try_files` directive in the server context _only applies if no location block +matches_, it is not a default which location blocks override. +