nginx学习http_auth_basic_module模块

 

 

对2.html页面做授权操作

先进行账号密码的生成  使用  htpasswd -c /etc/nginx/auth_conf  用户名

输入2次密码

(如果没有htpasswd,可以使用yum  -y install httpd-tools 进行安装)

然后可使用  more  /etc/nginx/auth_conf 查看

接着配置

 location ~ ^/2.html {
        root   /opt/app/code;
        auth_basic    'bobobobobobo';
        auth_basic_user_file /etc/nginx/auth_conf;  //生成的账号密码位置
        index  index.html index.htm;
   }

效果图:

 

按取消则会出现

 

posted @ 2017-10-30 23:10  spectrelb  阅读(386)  评论(0编辑  收藏  举报