Home  >  Article  >  Operation and Maintenance  >  Example analysis of nginx opening directory listing

Example analysis of nginx opening directory listing

WBOY
WBOYforward
2023-05-26 11:36:401558browse

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) displays the exact size of the file, the unit is byte; change it to off to display 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; After changing to on, the displayed file time 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 following Configuration

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

The above is the detailed content of Example analysis of nginx opening 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