Nginx autoindex: Enable directory listing on Nginx Web Server

How can I enable directory listing on Nginx web server in Linux? Directory listing can be enabled using the HttpAutoIndexModule, the one responsible for that function. The HTTP request is passed to the ngx_http_autoindex_module module when no index is found on your webpage.

Enabling directory listing for a website using Nginx is pretty much simple, it takes 2 minutes and you will be able to see your directories and files from the web browser to explore them in the same way you would do with your local files browser.

Nginx also allows you to enable directory listing for certain directories, instead of the whole website. Let’s take a look at ngx_http_autoindex_module syntax, and how to enable directory listing on Nginx.


ngx_http_autoindex_module module is the one in charge of enabling or disabling directory listing on Nginx. By default it comes disabled, but you can enable it using the following syntax, see below:

Syntax: autoindex on | off;
Default: autoindex off;
Context: http, server, location

How can I enable directory listing on Nginx for one single directory?

For this we will use the location directive, on any location block just add this:

location /nixcp {
	autoindex on;
	autoindex_exact_size off;
	autoindex_localtime on;

Restart Nginx to apply the changes

service nginx restart

Understanding the autoindex configuration

  • autoindex on – Enables Nginx auto indexing to browse your files from the web browser.
  • autoindex_exact_size off – This option will show you file sizes listed in KB,MB or GB.
  • autoindex_localtime on – This will show you file times.

Enable directory listing on the whole website

Nginx Directory listing can also be enabled on your full website if you use the same autoindex directive inside a server block if you use these options inside the server block. For example:

Nginx autoindex on server block configuration example, the way to enable directory listing on Nginx
Fig. 01. Nginx autoindex on server block configuration example


As you see, enabling nginx autoindex is really easy. It allows you to show file in Nginx from your web browser. Be aware this can be a security risk for your website, because enabling file browsing on Nginx can lead into potential information leaking for your web applications that can be later used to launch attacks against your website.

Further reading:

About the Author: Santiago Borges

Experienced Sr. Linux SysAdmin and Web Technologist, passionate about building tools, automating processes, fixing server issues, troubleshooting, securing and optimizing high traffic websites.

Leave a Reply

Your email address will not be published. Required fields are marked *