https://zhuanlan.zhihu.com/p/111228599
1. 安装 htpasswd 工具
1 2 3 4 5 6 7 8 9
| yum install httpd-tools -y
[sandu@bogon conf]$ sudo mkdir passwd [sandu@bogon conf]$ sudo htpasswd -c passwd/passwd sandu New password: Re-type new password: Adding password for user sandu [sandu@bogon conf]$ cat passwd/passwd sandu:$apr1$J5Sg0fQD$KDM3Oypj8Wf9477PHDIzA0
|
修改 nginx 配置文件
1 2 3 4 5 6 7 8 9 10
| server { listen 80; server_name localhost; ....... #新增下面两行 auth_basic "Please input password"; #这里是验证时的提示信息 auth_basic_user_file /usr/local/openresty/nginx/conf/passwd/passwd; # 这里是密码文件,可以填写绝对路径 location /{ ....... }
|