How to enable directory listing in Nginx

Enabling the Nginx Directory Index Listing 

Nginx is a popular web server that can also be used as a reverse proxy, caching, load balancing, and for other purposes. In this post, I'll show you how to enable and disable directory listing.




If you are using Nginx web server and want to display folder in Nginx by web, you must change "autoindex on;" in your conf file. By default, we cannot open directory from Nginx web.


Enable Directory listing : Open your nginx conf file and change.


server {
        listen 80 default_server;
        listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
        autoindex on; #for enable directory listing 
        server_name _;

        location / {
  try_files $uri $uri/ =404;
        }

}
 

 

How to disable Directory Indexing in Nginx. 

Here is the simple step to disable directory listing in Nginx. Go to the Nginx configuration file and turn off the indexing.

autoindex off;

 
You might be interested in this article :How to setup Nginx ingress using helm

Linux Guru

Welcome to my Linux blog! Hello Friends, I am Vishal Vyas. I am a DevOps engineer and expert in Linux and Cloud Computing. Also I am a Certified Kubernetes Administrator, I have a total 12 plus years of experience in the IT field and I have worked in various technologies. I write about Linux, AWS, DevOps and web Technologies, I have started this blog to share my technical knowledge with all, I am posting here what I learn from the latest web technologies and the likes.

Post a Comment

If you have any doubts, Please let me know

Previous Post Next Post