Nginx认证

Posted 谭普利特

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Nginx认证相关的知识,希望对你有一定的参考价值。

nginx 的 ngx_http_auth_basic_module模块允许通过使用“HTTP基本认证”协议验证用户名和密码来限制对资源的访问。

配置举例:

location / {
    auth_basic           "closed site";
    auth_basic_user_file conf/htpasswd;
}

 

#生成htpasswd密码文件,并指定账号、密码

[[email protected] ~]# cd /usr/local/nginx/conf/

 [[email protected] conf]# htpasswd -bc /usr/local/nginx/conf/htpasswd username passwd
   Adding password for user username

 [[email protected] conf]chmod 400 htpasswd

   重启Nginx

 


以上是关于Nginx认证的主要内容,如果未能解决你的问题,请参考以下文章