目錄
- Nginx基礎子產品
- 1.Nginx目錄索引
- 1.1 文法
- 1.2 autoindex常用參數
- 1.3 代碼使用方法
Nginx基礎子產品
官方幫助資訊
1.Nginx目錄索引
http_autoindex_module子產品
1.1 文法
預設是不允許列出整個目錄浏覽下載下傳
syntax: autoindex
on
|
off
;
Default: autoindex off;
Contxte: http,server,location
1.2 autoindex常用參數
- autoindex_exact_size off; //預設為on,顯示出檔案的确切大小,機關bytes。 修改為off,顯示出檔案大概大小,機關是KB或者MB或者GB
- autoindex_localtime on; //預設為off,顯示的檔案時間為GMT時間。修改為no,顯示的檔案時間為檔案伺服器時間
- charset utf-8,gbk; // 預設中文目錄亂碼,解決亂碼
1.3 代碼使用方法
server {
listen 80;
server_name localhost;
location / {
root /html;
autoindex on; //開啟目錄索引
autoindex_exact_size off; //顯示出檔案的确切大小,機關
charset utf-8,gdk; //預設中文目錄亂碼,解決亂碼。
autoindex_localtime on; //顯示的檔案時間為檔案伺服器時間
}
}
[root@nginx_web1 ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@nginx_web1 ~]# systemctl restart nginx