1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| 1,生成密码文件: sudo htpasswd -c -d /etc/nginx/pass_file guest 2,修改 /etc/nginx/conf.d/default.conf: ## 视频地址加权限 location ~ /video { auth_basic "Restricted"; auth_basic_user_file /etc/nginx/pass_filecoco; ##请使用绝对路径 root /usr/share/nginx/html; ##host 地址,不然认证通过之后,找不到对应的文件 autoindex on;##自动显示目录 autoindex_exact_size off;##人性化方式显示文件大小否则以byte显示 autoindex_localtime on;##按服务器时间显示,否则以gmt时间显示 } 3, 验证配置是否正确 sudo /usr/sbin/nginx -t -c /etc/nginx/nginx.conf 4, 重启nginx sudo systemctl restart nginx
|