2

I am trying to get nginx to ignore index.html files and always show a directory listing from the autoindex module.

If I remove my index line, nginx still defaults to serving index.html files, so that is not a solution.

A similar question was asked on Stack Overflow, but I am looking for a solution that does not involve inventing a bogus file name, if such a solution exists (not to mention the thread is off topic there).

How can I change my index directive to tell nginx to never show index files?

Gerald Schneider
  • 19,757
  • 8
  • 52
  • 79

2 Answers2

4

Instead of removing the index directive, you should set it to a name which is not reasonably expected to exist, so that it never matches any file.

For example:

index X6XewZMsmreGIxx1lCdp0Yo1X4qHTivW;

You may not like this solution. It is a little inelegant. But it works well and does exactly what you want, while nothing else does.

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
1

Remove (comment out) the index directive. With for example the Debian nginx package, autoindex (or fancyindex) attempts a directory index.

As an alternative, bogus index file isn't elegant, but it isn't expensive either. Probably only needs a couple system calls to check file non existence.

John Mahowald
  • 30,009
  • 1
  • 17
  • 32