打开某个站点的配置文件
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 /;
}