How to enable nginx directory listing

WBOY
Release: 2023-05-14 11:55:13
forward
996 people have browsed it

nginx opens the column directory

When you want nginx to exist as a file download server, you need to open the nginx column directory

server {     location download {         autoindex on;          autoindex_exact_size off;         autoindex_localtime on;     } }
Copy after login

autoindex_exact_size: is on (default) When it is off, it displays the exact size of the file, the unit is byte; when it is changed to off, it displays the approximate size of the file, the unit is KB or MB or GB

autoindex_localtime: when it is off (default), the file time displayed is GMT time; when it is changed on After that, the file time displayed is the server time

By default, when accessing the listed txt and other files, the content of the file will be displayed on the browser. If you want the browser to download it directly, add the configuration below

if ($request_filename ~* ^.*?\.(txt|pdf|jpg|png)$) {     add_header Content-Disposition 'attachment'; }
Copy after login

The above is the detailed content of How to enable nginx directory listing. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!