Enable Directory Listing in Nginx
To enable directory listing in Nginx, add following to server configuration.
1 |
autoindex on; |
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
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; } } |