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

Example analysis of nginx opening directory listing

WBOY
Release: 2023-05-26 11:36:40
forward
1589 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) 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';
}
Copy after login

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!

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