您的位置:首页 > 理论基础 > 计算机网络

配置nginx身份验证(ngx_http_auth_basic_module)

2020-02-01 15:11 591 查看

编译的时候默认参数即可

./configure --with-pcre=../pcre --with-zlib=../zlib --with-http_ssl_module --with-openssl=../openssl --with-http_sub_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_flv_module --with-debug

 

修改配置文件

location / {
            root   /usr/local/nginx/html;
                auth_basic "Auth";
                 auth_basic_user_file /usr/local/nginx/conf/htpasswd; 
            index  index.html index.htm;
}

 

auth_basic "Auth"中的Auth是弹出框(输入用户名和密码)的标题

auth_basic_user_file /usr/local/nginx/conf/htpasswd; 中的/usr/local/nginx/conf/htpasswd是保存密码的文件

密码文件生成,需要apt-get install mini-httpd

htpasswd -c /usr/local/nginx/conf/htpasswd 用户名

 

配置好后,重启,应该就可以了。

注:我在配置的时候,由于IE9缓存数据,造成不弹出身份验证框。清楚缓存就好了。 

 

转载于:https://www.cnblogs.com/xewnwsl2001/archive/2010/12/14/1905648.html

  • 点赞
  • 收藏
  • 分享
  • 文章举报
dfnpa06442 发布了0 篇原创文章 · 获赞 0 · 访问量 102 私信 关注
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐