跳转到nginx配置目录
cd /etc/nginx
生成用户名密码对
printf "USERNAME:$(openssl passwd -crypt PASSWORD)\n" >> conf.d/passwd
修改nginx配置文件
location /files/ {
root /pathtoroot
auth_basic "在线服务";
auth_basic_user_file conf.d/passwd;
autoindex on;
}
重启nginx
nginx -s reload