1.目錄列表(directory listing)
nginx讓目錄中的文件以列表的形式展現只需要一條指令
autoindex on;
autoindex可以放在location中,只對當前l(fā)ocation的目錄起作用,
nginx目錄列表和目錄訪問權限設置
。你也可以將它放在server指令塊則對整個站點都起作用;蛘叻诺絟ttp指令塊,則對所有站點都生效。下面是一個簡單的例子:
server {
listen 80;
server_name domain.com ;
access_log /var/...........................;
root /path/to/root;
location / {
index index.php index.html index.htm;
}
location /somedir {
autoindex on;
}
}2.nginx禁止訪問某個目錄
跟Apache的Deny from all類似,nginx有deny all指令來實現,
電腦資料
《nginx目錄列表和目錄訪問權限設置》(http://www.ishadingyu.com)。禁止對叫dirdeny目錄的訪問并返回403 Forbidden,可以使用下面的配置:
location /dirdeny {
deny all;
return 403;
}