ScaleScaleScaleScale

Tips / Nginx


How to enable Nginx directory listing

HttpAutoIndexModule is the module that handles the Nginx directory listing. Enabling directory listing in a directory in nginx is very simple using the autoindex option inside the location directive. Directory listing can also be enabled site-wide if you use these options inside the server block.

Enabling Nginx Directory Listing

On any location context, just add autoindex on;

location /testing {
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
}

But there are another two interesting options too, I’m talking about autoindex_exact_size and autoindex_localtime, let’s take a look:

location /testing {
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
}

Restart to apply changes:

service nginx restart

A brief explanation of each option

autoindex on – enables auto indexing on
autoindex_exact_size off – Useful if you need file sizes rounded in KB, MB, GB, etc (default is set to Bytes)
autoindex_localtime on – Enables file times to be shown locally.

Autoindex Directive Resume

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

Popular search terms:

  • nginx autoindex
  • nginx directory listing
  • nginx 205 directory index
  • nginx allow directory listing
profile

Esteban Borges

Linux Geek, Webperf Addict, Nginx Fan. CTO @Infranetworking