Home  >  Article  >  Operation and Maintenance  >  How to enable nginx directory listing

How to enable nginx directory listing

WBOY
WBOYforward
2023-05-14 11:55:13997browse

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;     } }

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'; }

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!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete