zoukankan      html  css  js  c++  java
  • Nginx密码验证 ngx_http_auth_basic_module模块

    有时候我们需要限制某些目录只允许指定的用户才可以访问,我们可以给指定的目录添加一个用户限制。
    nginx给我们提供了ngx_http_auth_basic_module模块来实现这个功能。
    模块ngx_http_auth_basic_module允许使用“HTTP基本认证”协议验证用户名和密码来限制对资源的访问。

    1. location / {
    2. auth_basic "closed site";
    3. auth_basic_user_file conf/htpasswd;
    4. }
    • 语法: auth_basic string | off;
      默认值:
      auth_basic off;
      上下文: http, server, location, limit_except
      开启使用“HTTP基本认证”协议的用户名密码验证。 指定的参数被用作 域。 参数off可以取消继承自上一个配置等级 auth_basic 指令的影响。
    • 语法: auth_basic_user_file file;
      默认值: —
      上下文: http, server, location, limit_except
      指定保存用户名和密码的文件,格式如下:
    1. # comment
    2. name1:password1
    3. name2:password2:comment
    4. name3:password3

    密码应该使用crypt()函数加密。 可以用Apache发行包中的htpasswd命令来创建此类文件。





  • 相关阅读:
    oo第八次作业--5,6,7次作业总结
    OO前三次作业总结
    软工总结
    黄衫感想博客
    软工结对编程博客
    软工第一次阅读
    软工第0次作业
    OO第四次博客
    OO第三次博客
    OO第二次博客
  • 原文地址:https://www.cnblogs.com/snifferhu/p/6148900.html
Copyright © 2011-2022 走看看