1. 程式人生 > >nginx開啟目錄瀏覽

nginx開啟目錄瀏覽

開啟某個站點的配置檔案

server
{
autoindex on;#開啟目錄瀏覽
autoindex_exact_size off;#顯示出檔案的大概大小,單位是kB或者MB或者GB,低於kb的預設為bytes並且不顯示單位名
autoindex_localtime on;#顯示的檔案時間由GMT時間改為伺服器時間
autoindex_format html;  #顯示的格式    xml|json|html


auth_basic "MyPath Authorized";           #許可權驗證標題        
auth_basic_user_file /usr/local
/nginx/conf/auth_password; #呼叫許可權驗證檔案 }

使用htpasswd生成驗證檔案

htpasswd -c ~/auth df

虛擬對映

location /df {
 autoindex  on;                        #自動顯示目錄
      autoindex_exact_size  off;            #改為off後,顯示出檔案的大概大小,單位是kB或者MB或者GB;即人性化方式顯示檔案大小否則以byte顯示
      autoindex_localtime on;               #顯示的檔案時間為檔案的伺服器時間;即按伺服器時間顯示
limit_rate_after 10m; #10m之後下載速度為10k limit_rate 10k; alias /; }

參考