Enable Directory Listing in Nginx
To enable directory listing in Nginx, add following to server configuration.
autoindex on;
Example
server { listen 80 default_server; listen [::]:80 default_server; root /var/www/html; autoindex on; index index.php index.html index.htm; server_name _; location / { try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { include snippets/fastcgi-php.conf; proxy_read_timeout 600; fastcgi_read_timeout 600; fastcgi_send_timeout 600; fastcgi_intercept_errors on; fastcgi_buffers 16 16k; fastcgi_buffer_size 32k; fastcgi_pass unix:/run/php/php7.0-fpm.sock; } }
If you need it for a specific folder, add
server { listen 80 default_server; listen [::]:80 default_server; root /var/www/html; index index.php index.html index.htm; server_name _; location / { try_files $uri $uri/ /index.php?$args; } location /myfiles { autoindex on; } location ~ \.php$ { include snippets/fastcgi-php.conf; proxy_read_timeout 600; fastcgi_read_timeout 600; fastcgi_send_timeout 600; fastcgi_intercept_errors on; fastcgi_buffers 16 16k; fastcgi_buffer_size 32k; fastcgi_pass unix:/run/php/php7.0-fpm.sock; } }