Would you like to learn how to disable the directory listing on the Nginx server? In this tutorial, we are going to configure the Nginx server to block the directory browsing feature.

• Ubuntu 18
• Ubuntu 19
• Ubuntu 20
• Nginx 1.18.0

Equipment list

The following section presents the list of equipment used to create this tutorial.

As an Amazon Associate, I earn from qualifying purchases.

Tutorial Nginx – Disable directory listing

Install the Nginx server.

Copy to Clipboard

Edit the Nginx configuration file for the default website.

Copy to Clipboard

Add the following line to the configuration file.

Copy to Clipboard

Here is the file, before our configuration.

Copy to Clipboard

Here is the file, after our configuration.

Copy to Clipboard

Restart the Nginx service.

Copy to Clipboard

In our example, the directory listing feature was disabled on the Nginx server.

From a remote computer, open the browser and try to access a directory of the Nginx server.

• http://192.168.2.113/test

The Nginx server will display an error message.

Nginx - Disable directory listing

Congratulations! You configured the Nginx server to disable the directory browsing feature.