# Nginx 0.8.54: Index files bug?

**URL:** <https://www.ruby-forum.com/t/nginx-0-8-54-index-files-bug/203057>\
**Category:** NGINX\
**Created:** [February 11, 2011, 12:46pm UTC](https://www.ruby-forum.com/t/nginx-0-8-54-index-files-bug/203057 "2011-02-11T12:46:38Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [February 11, 2011, 12:46pm UTC](https://www.ruby-forum.com/t/nginx-0-8-54-index-files-bug/203057/1 "2011-02-11T12:46:38Z")

</div>

Just noticed an issue with my 0.8.54 installation.

1. URL = [www.site.com](http://www.site.com), Result = 500 error

```auto
server {
...
  index index.html;
  location / {
    try_files $uri $uri/;
  }
}
```

1. URL = [www.site.com](http://www.site.com), Result = 500 error

```auto
server {
...
  location / {
  index index.html;
    try_files $uri $uri/;
  }
}
```

1. URL = [www.site.com](http://www.site.com), Result = 200 OK

```auto
server {
...
  location / {
    try_files $uri $uri/index.html;
  }
}
```

1. URL = [Custom Application Development Software for Business - Salesforce.com](http://www.site.com/index.html), Result = 200 OK

```auto
server {
...
  location / {
    try_files $uri $uri/;
  }
}
```

It seems that the index module does not work with the try\_files  
directive. Would have expected the trying of ‘$uri/’ to include the  
defined index but it doesn’t do so.

Anyone else notice this?

Posted at Nginx Forum:

> **[Nginx 0.8.54: Index files bug?](https://forum.nginx.org/read.php?2,174111,174111#msg-174111)**
>
> Just noticed an issue with my 0.8.54 installation. 1. URL = www.site.com, Result = 500 error \[code\] server { ... index index.html; location / { try\_files $uri $uri/; } } \[/code\] 2. URL = www.site.com, R

---

<div class="post-metadata">

**Author:** ![Dayo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9dc877/32.png) [@Dayo](https://www.ruby-forum.com/u/Dayo)\
**Post date:** [February 11, 2011, 12:51pm UTC](https://www.ruby-forum.com/t/nginx-0-8-54-index-files-bug/203057/2 "2011-02-11T12:51:38Z")

</div>

On Fri, Feb 11, 2011 at 06:45:25AM -0500, Dayo wrote:

> }  
> }  
> [/code]
> 
> It seems that the index module does not work with the try\_files  
> directive. Would have expected the trying of ‘$uri/’ to include the  
> defined index but it doesn’t do so.
> 
> Anyone else notice this?

What is in error\_log ?

–  
Igor S.

> **[Igor Sysoev](http://sysoev.ru/en/)**

---

<div class="post-metadata">

**Author:** ![Dayo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9dc877/32.png) [@Dayo](https://www.ruby-forum.com/u/Dayo)\
**Post date:** [February 11, 2011, 1:17pm UTC](https://www.ruby-forum.com/t/nginx-0-8-54-index-files-bug/203057/3 "2011-02-11T13:17:57Z")

</div>

## Igor S. Wrote:

> > It seems that the index module does not work  
> > with the try\_files  
> > directive. Would have expected the trying of  
> > ‘$uri/’ to include the  
> > defined index but it doesn’t do so.
> > 
> > Anyone else notice this?
> 
> What is in error\_log ?

Nothing.

Here is my Nginx -V

[root@server01 ~]# nginx -V  
nginx version: nginx/0.8.54  
built by gcc 4.1.2 20080704 (Red Hat 4.1.2-48)  
TLS SNI support disabled  
configure arguments:  
–user=nginx  
–group=nginx  
–prefix=/usr/share/nginx  
–sbin-path=/usr/sbin/nginx  
–conf-path=/etc/nginx/nginx.conf  
–error-log-path=/var/log/nginx/error.log  
–http-log-path=/var/log/nginx/access.log  
–http-client-body-temp-path=/var/lib/nginx/tmp/client\_body  
–http-proxy-temp-path=/var/lib/nginx/tmp/proxy  
–http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi  
–pid-path=/var/run/nginx.pid  
–lock-path=/var/lock/subsys/nginx  
–with-http\_ssl\_module  
–with-http\_realip\_module  
–with-http\_stub\_status\_module  
–with-http\_perl\_module  
–with-mail  
–with-mail\_ssl\_module  
–with-cc-opt=‘-O2 -g -pipe -Wall -Wp,-D\_FORTIFY\_SOURCE=2 -fexceptions  
-fstack-protector  
–param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic  
-fasynchronous-unwind-tables’  
–add-module=/usr/src/redhat/BUILD/nginx-0.8.54/nginx-upstream-fair  
–add-module=/usr/src/redhat/BUILD/nginx-0.8.54/ngx\_cache\_purge-1.2  
–add-module=/usr/src/redhat/BUILD/nginx-0.8.54/ngx-headers-more  
–add-module=/usr/src/redhat/BUILD/nginx-0.8.54/ngx-devel-kit  
–add-module=/usr/src/redhat/BUILD/nginx-0.8.54/ngx-echo-module  
–add-module=/usr/src/redhat/BUILD/nginx-0.8.54/ngx-lua-module  
–without-http\_autoindex\_module  
–without-http\_empty\_gif\_module  
–without-http\_memcached\_module  
–without-http\_scgi\_module  
–without-http\_split\_clients\_module  
–without-http\_ssi\_module  
–without-http\_upstream\_ip\_hash\_module  
–without-http\_uwsgi\_module

As shown, I do have a few 3rd party modules and I disabled a few  
standard ones I don’t use.

I did notice a while back that stuff did not work when the perl module  
was disabled and perhaps disabling the autoindex module is affecting  
this.

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,174111,174119#msg-174119](http://forum.nginx.org/read.php?2,174111,174119#msg-174119)

---

<div class="post-metadata">

**Author:** ![Dayo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9dc877/32.png) [@Dayo](https://www.ruby-forum.com/u/Dayo)\
**Post date:** [February 11, 2011, 2:35pm UTC](https://www.ruby-forum.com/t/nginx-0-8-54-index-files-bug/203057/4 "2011-02-11T14:35:10Z")

</div>

## Igor S. Wrote:

> Standard nginx modules logs a reason of 500 error.

I have done a plain vanilla build of v0.8.54 without any third party  
modules and I both still get the same results and do not have anything  
in the error log.

Not sure why nothing is getting logged but at least I know this is not  
down to the third party modules.

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,174111,174132#msg-174132](http://forum.nginx.org/read.php?2,174111,174132#msg-174132)

---

<div class="post-metadata">

**Author:** ![Dayo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9dc877/32.png) [@Dayo](https://www.ruby-forum.com/u/Dayo)\
**Post date:** [February 11, 2011, 2:48pm UTC](https://www.ruby-forum.com/t/nginx-0-8-54-index-files-bug/203057/5 "2011-02-11T14:48:22Z")

</div>

On Fri, Feb 11, 2011 at 08:33:44AM -0500, Dayo wrote:

> ## Igor S. Wrote:
> 
> > Standard nginx modules logs a reason of 500 error.
> 
> I have done a plain vanilla build of v0.8.54 without any third party  
> modules and I both still get the same results and do not have anything  
> in the error log.
> 
> Not sure why nothing is getting logged but at least I know this is not  
> down to the third party modules.

Could you create a debug log ?

> **[A debugging log](http://nginx.org/en/docs/debugging_log.html)**

–  
Igor S.

> **[Igor Sysoev](http://sysoev.ru/en/)**

---

<div class="post-metadata">

**Author:** ![Dayo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9dc877/32.png) [@Dayo](https://www.ruby-forum.com/u/Dayo)\
**Post date:** [February 11, 2011, 3:14pm UTC](https://www.ruby-forum.com/t/nginx-0-8-54-index-files-bug/203057/6 "2011-02-11T15:14:42Z")

</div>

```auto
server {
...
  index index.html;
  location / {
                error_log /path/to/log debug;
    try_files $uri $uri/;
  }
}
```

…gives me an empty error log file.

I don’t think my isp has cached the response because as soon as I change  
to …

```auto
server {
...
  index index.html;
  location / {
    try_files $uri $uri/ @proxy;
  }
}
```

It starts working … using the apache index files setup.

Wonder whether anyone else can reproduce

Posted at Nginx Forum:

> **[Re: Nginx 0.8.54: Index files bug?](https://forum.nginx.org/read.php?2,174111,174140#msg-174140)**
>
> Just noticed an issue with my 0.8.54 installation. 1. URL = www.site.com, Result = 500 error \[code\] server { ... index index.html; location / { try\_files $uri $uri/; } } \[/code\] 2. URL = www.site.com, R

---

<div class="post-metadata">

**Author:** ![Dayo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9dc877/32.png) [@Dayo](https://www.ruby-forum.com/u/Dayo)\
**Post date:** [February 11, 2011, 1:46pm UTC](https://www.ruby-forum.com/t/nginx-0-8-54-index-files-bug/203057/7 "2011-02-11T13:46:12Z")

</div>

On Fri, Feb 11, 2011 at 07:16:22AM -0500, Dayo wrote:

> > What is in error\_log ?  
> > –user=nginx  
> > –lock-path=/var/lock/subsys/nginx  
> > –add-module=/usr/src/redhat/BUILD/nginx-0.8.54/nginx-upstream-fair  
> > –without-http\_ssi\_module  
> > –without-http\_upstream\_ip\_hash\_module  
> > –without-http\_uwsgi\_module
> 
> As shown, I do have a few 3rd party modules and I disabled a few  
> standard ones I don’t use.
> 
> I did notice a while back that stuff did not work when the perl module  
> was disabled and perhaps disabling the autoindex module is affecting  
> this.

Standard nginx modules logs a reason of 500 error.

–  
Igor S.

> **[Igor Sysoev](http://sysoev.ru/en/)**

---

<div class="post-metadata">

**Author:** ![Dayo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9dc877/32.png) [@Dayo](https://www.ruby-forum.com/u/Dayo)\
**Post date:** [February 11, 2011, 4:38pm UTC](https://www.ruby-forum.com/t/nginx-0-8-54-index-files-bug/203057/8 "2011-02-11T16:38:43Z")

</div>

Narrowed the issue down to the try\_files directive.

These configurations work:

1. URL = [www.site.com](http://www.site.com), Result = 200 OK

```auto
server {
...
  index index.html;
  location / {
    #try_files $uri $uri/;
  }
}
```

1. URL = [www.site.com](http://www.site.com), Result = 200 OK

```auto
server {
...
  location / {
          index index.html;
    #try_files $uri $uri/;
  }
}
```

Posted at Nginx Forum:

> **[Re: Nginx 0.8.54: Index files bug?](https://forum.nginx.org/read.php?2,174111,174168#msg-174168)**
>
> Just noticed an issue with my 0.8.54 installation. 1. URL = www.site.com, Result = 500 error \[code\] server { ... index index.html; location / { try\_files $uri $uri/; } } \[/code\] 2. URL = www.site.com, R

---

<div class="post-metadata">

**Author:** ![Dayo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9dc877/32.png) [@Dayo](https://www.ruby-forum.com/u/Dayo)\
**Post date:** [February 11, 2011, 4:38pm UTC](https://www.ruby-forum.com/t/nginx-0-8-54-index-files-bug/203057/9 "2011-02-11T16:38:05Z")

</div>

Hello!

On Fri, Feb 11, 2011 at 09:13:06AM -0500, Dayo wrote:

> …gives me an empty error log file.

It should log something like “rewrite or internal redirection  
cycle” at “error” level. Obviously enough your config creates an  
infinite loop on processing “/” as you set try\_files’s fallback to  
effectively the same uri, just with extra “/” added.

No idea why you have no logs - most likely you did something wrong  
(e.g. nginx has no access rights to write the file in question and  
config wasn’t actually loaded due to this error, but you’ve  
overlooked related messages in global error\_log).

> }  
> [/code]
> 
> It starts working … using the apache index files setup.

This one should use index.html as an index (and fallback to @proxy  
if no index.html found or there is no directory at all).

Maxim D.

---

<div class="post-metadata">

**Author:** ![Dayo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9dc877/32.png) [@Dayo](https://www.ruby-forum.com/u/Dayo)\
**Post date:** [February 11, 2011, 4:59pm UTC](https://www.ruby-forum.com/t/nginx-0-8-54-index-files-bug/203057/10 "2011-02-11T16:59:24Z")

</div>

On Fri, Feb 11, 2011 at 10:43:19AM -0500, Dayo wrote:

> > try\_files’s fallback to  
> > effectively the same uri, just with extra “/”  
> > added.
> 
> Did you see my previous post?  
> When I comment out the try files directive, the index works.

As Maxim already said you should see in the log

[error] … rewrite or internal redirection cycle while  
internal redirect to “/”

–  
Igor S.

> **[Igor Sysoev](http://sysoev.ru/en/)**

---

<div class="post-metadata">

**Author:** ![Dayo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9dc877/32.png) [@Dayo](https://www.ruby-forum.com/u/Dayo)\
**Post date:** [February 11, 2011, 4:44pm UTC](https://www.ruby-forum.com/t/nginx-0-8-54-index-files-bug/203057/11 "2011-02-11T16:44:21Z")

</div>

Hi Maxim!

## Maxim D. Wrote:

> No idea why you have no logs - most likely you did  
> something wrong  
> (e.g. nginx has no access rights to write the file  
> in question and  
> config wasn’t actually loaded due to this error,  
> but you’ve  
> overlooked related messages in global error\_log).

The error log file does log other errors.

> This one should use index.html as an index (and  
> fallback to @proxy  
> if no index.html found or there is no directory at  
> all).  
> Correct. It only works because it is falling back to apache.

Did you see my previous post?  
When I comment out the try files directive, the index works.

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,174111,174171#msg-174171](http://forum.nginx.org/read.php?2,174111,174171#msg-174171)

---

<div class="post-metadata">

**Author:** ![Dayo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9dc877/32.png) [@Dayo](https://www.ruby-forum.com/u/Dayo)\
**Post date:** [February 11, 2011, 5:32pm UTC](https://www.ruby-forum.com/t/nginx-0-8-54-index-files-bug/203057/12 "2011-02-11T17:32:00Z")

</div>

Hi Maxim!

## Maxim D. Wrote:

> is an infinite loop. It is expected to generate  
> 500 for  
> directories. Under no conditions it will allow  
> index to work.

OK. That is clear enough.

My normal setup is  
location / {  
try\_files $uri $uri/ @proxy;  
}  
I just ran the ‘try\_files $uri $uri/;’ as a test to try to see whether  
the file gets served by Nginx or by the backend if it is the index.html  
being called.

I see now from your explanation that the test would always fail.

Thanks

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,174111,174183#msg-174183](http://forum.nginx.org/read.php?2,174111,174183#msg-174183)

---

<div class="post-metadata">

**Author:** ![Dayo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9dc877/32.png) [@Dayo](https://www.ruby-forum.com/u/Dayo)\
**Post date:** [February 11, 2011, 5:10pm UTC](https://www.ruby-forum.com/t/nginx-0-8-54-index-files-bug/203057/13 "2011-02-11T17:10:42Z")

</div>

Hello!

On Fri, Feb 11, 2011 at 10:43:19AM -0500, Dayo wrote:

> > try\_files’s fallback to
> 
> The error log file does log other errors.

This is fine, but doesn’t explain why don’t see the one in  
question. It’s hard to say anything without seeing the full  
config.

> > This one should use index.html as an index (and  
> > fallback to @proxy  
> > if no index.html found or there is no directory at  
> > all).  
> > Correct. It only works because it is falling back to apache.
> 
> Did you see my previous post?  
> When I comment out the try files directive, the index works.

Again:

```
location / {
    try_files $uri $uri/;
}

```

is an infinite loop. It is expected to generate 500 for  
directories. Under no conditions it will allow index to work.

This is what you wrote in your config: check if file (not  
directory) “$uri” exists, if not - do internal redirect to  
“$uri/”.

If you want nginx to return 404 if no file or directory exists -  
use

```
location / {
    try_files $uri $uri/ =404;
}

```

Or, better, just don’t use try\_files - it’s not needed here.  
Index and static modules will generate 404 as appropriate.

Maxim D.

---

<div class="post-metadata">

**Author:** ![Dayo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9dc877/32.png) [@Dayo](https://www.ruby-forum.com/u/Dayo)\
**Post date:** [February 11, 2011, 6:55pm UTC](https://www.ruby-forum.com/t/nginx-0-8-54-index-files-bug/203057/14 "2011-02-11T18:55:22Z")

</div>

Hi Maxim! Hi Igor!

## Maxim D. Wrote:

> > The error log file does log other errors.
> 
> This is fine, but doesn’t explain why don’t see  
> the one in  
> question. It’s hard to say anything without  
> seeing the full  
> config.

I went back to look over my config in detail and noticed I was  
generating two separate error logs. The error was indeed being logged  
by the debug as stated.

Thanks again for your help.

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,174111,174208#msg-174208](http://forum.nginx.org/read.php?2,174111,174208#msg-174208)
