How does Nginx enable the directory browsing function (autoindex)

Source: Internet
Author: User

Open the nginx. conf file and add it to the location server or http segment.

The code is as follows: Copy code

Autoindex on;

We recommend that you add the following two parameters:

The code is as follows: Copy code

Autoindex_exact_size off;

The default value is on. The exact size of the file is displayed, in bytes.
After changing to off, the approximate size of the file is displayed. The unit is kB, MB, or GB.

The code is as follows: Copy code

Autoindex_localtime on;

The default value is off. The displayed file Time Is GMT.
After changing to on, the displayed File time is the file server time

The code is as follows: Copy code
Location /{
Root/var/www/html;
Autoindex on;
}

This code directly lists the/var/www/html directory as the root directory.


If we want to display only one website or one directory, it is very easy to modify all the. conf files of the website. Modify it as follows:

The code is as follows: Copy code

Server {
Listen 80;
Charset UTF-8;
Server_name localhost;
Root/www/web/default;

Location /{
Autoindex on;
Autoindex_exact_size off;
Autoindex_localtime on;
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.