Edho Arief
June 25, 2012 09:48PM
On Tue, Jun 26, 2012 at 6:00 AM, whiskybar <nginx-forum@nginx.us> wrote:
> Why is it my first configuration returns 403 while my second
> configuration returns 404?
>
> I looked into logs and it seems my first configuration triggers the
> index module which is set to the default index.html, finds nothing and
> returns 403. Why isn't the =404 triggered? And why is the index module
> triggered at all?
>
> server {
>    root /var;
>    try_files $uri =404;
>    location / {
>    }
> }
>
> My second configuration works more like I expected; but then, why isn't
> the index module triggered as well? Does try_files disable the index
> module somehow?
>
> server {
>    root /var;
>    location / {
>        try_files $uri =404;
>    }
> }
>
> Can someone explain how nginx goes to decide what to do?
> Thank you
>

try_files doesn't trigger index; you must try $uri/ explicitly.
Therefore, the correct try_files you need is:
try_files $uri $uri/ =404;

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

try_files and index

whiskybar June 25, 2012 07:00PM

Re: try_files and index

Edho Arief June 25, 2012 09:48PM

Re: try_files and index

whiskybar June 26, 2012 03:18AM

Re: try_files and index

Edho Arief June 26, 2012 03:24AM

Re: try_files and index

shahzaib mushtaq June 26, 2012 03:34AM

Re: try_files and index

Maxim Dounin June 26, 2012 03:32AM

Re: try_files and index

whiskybar June 26, 2012 03:47AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 272
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready