When reading the ThinkPHP document, I saw the following text: In order to prevent some servers from turning on directory browsing permissions and being able to directly enter the URL address in the browser to view the directory, the system has enabled the directory security file mechanism by default and will automatically When generating the directory, a blank index.html file is generated. Of course, the name of the security file can be set. For example, if you want to define the security file as default.html, you can add it in the entry file.
I hate redundant index.html, so I want to turn off the directory browsing permission directly. So the question is, how to turn off and turn on this permission in nginx?
The following is the answer I found on Baidu:
1. Directory listing
nginx only requires one command to display the files in the directory in the form of a list
autoindex on;
autoindex can be placed in location and will only work on the directory of the current location. You can also put it in the server directive block and it will apply to the entire site. Or put it in the http command block, it will take effect on all sites.
Here is a simple example:
2.nginx prohibits access to a certain directory
Similar to Apache’s Deny from all, nginx has the deny all instruction to implement it.
To disable access to the dirdeny directory and return 403 Forbidden, you can use the following configuration: