[PATCH] http_core: Do not match a file for a directory in try_files

Sergey Kandaurov pluknet at nginx.com
Wed Jan 21 16:21:32 UTC 2015


On Jan 21, 2015, at 2:54 AM, Damien Tournoud <damien at commerceguys.com> wrote:
> # HG changeset patch
> # User Damien Tournoud <damien at commerceguys.com>
> # Date 1421796392 -3600
> #      Wed Jan 21 00:26:32 2015 +0100
> # Node ID c8f2fbe53f5df811dcaada94d3eca6c34070c610
> # Parent  0a198a517eaf48baad03a76b182698c50496d380
> http_core: Do not match a file for a directory in try_files.
> 
> A try_files directive with a file match (i.e. something
> not ending with a "/") does not match a directory of
> the same name.
> 
> But a try_files directive with a directory match like this:
> 
>  try_files $uri/ =404;
> 
> ... does currently match a *file* of the same name.
> 

Indeed, it is odd to lookup a regular file with a trailing
slash, since this is generally only allowed for directories.

> 
> diff -r 0a198a517eaf -r c8f2fbe53f5d src/http/ngx_http_core_module.c
> --- a/src/http/ngx_http_core_module.c	Wed Jan 14 09:03:35 2015 +0300
> +++ b/src/http/ngx_http_core_module.c	Wed Jan 21 00:26:32 2015 +0100
> @@ -1353,7 +1353,7 @@
>             continue;
>         }
> 
> -        if (of.is_dir && !test_dir) {
> +        if (of.is_dir != test_dir) {
>             continue;
>         }
> 

The patch looks good to me.

-- 
Sergey Kandaurov



More information about the nginx-devel mailing list