用户在访问时,需要先输入账户和密码,认证通过后才可以访问网站信息,主要用于企业内部人员访问的地址
- 官方文档地址
http://nginx.org/en/docs/http/ngx_http_auth_basic_module.html
-
server配置
location / { auth_basic "study site"; auth_basic_user_file /application/nginx/conf/htpasswd; root html; index index.html index.htm; }
-
生成密码文件
安装httpd-tools工具yum install httpd-tools -y
检查是否安装htpasswd
[root@study conf]# rpm -qf /usr/bin/htpasswd
httpd-tools-