Force nginx to always autoindex and ignore index.html files?

Maximillian Laumeister asked:

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?

My answer:

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.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.