1、autoindex參數詳解
autoindex on; #on開啓目錄瀏覽;
autoindex_exact_size off; #off顯示出文件的大概大小,單位是kB或者MB或者GB;默認爲on, 顯示出⽂件的確切⼤⼩,單位是bytes;
autoindex_localtime on; #顯示的⽂件時間爲⽂件的服務器時間。默認爲off,顯示的⽂件時間爲GMT時間;
charset utf-8,gbk; #默認中文目錄亂碼,添加上解決亂碼問題;
2、配置下載站點
[root@nginx ~]# vim /usr/local/nginx/conf/nginx.conf
location /download {
root html;
autoindex on;
autoindex_localtime on;
autoindex_exact_size off;
charset utf-8; #解決中文顯示亂碼問題
alias /soft; #配置目錄索引的路徑(絕對路徑)
limit_conn addr 2; #限制同一ip的併發連接數
limit_rate_after 20m; #20m之後開始限速
limit_rate 100k; #限速爲100kb/s
}
3、在html目錄下創建download目錄
[root@nginx html]# tree download/
download/
├── 1.txt
├── 2.txt
├── 3.txt
└── soft
4、訪問Nginx-web測試界面