nginx HttpAuthBasicModule身份认证配置auth_basic



nginx HttpAuthBasicModule身份认证配置auth_basic
 
http://wiki.nginx.org/HttpAuthBasicModule
 
1. 首先生成密码
 
Passwords must be encoded by function crypt(3). If Apache is installed, 
you can create the password file using the htpasswd program included.
 
crypt() 函数在php、perl里均有,盐值与input一样就可以。
<?php
echo crypt($argv[1], $argv[1]),"\n";
?>
 
2. 添加至配置文件
  www.2cto.com  
nginx.conf 配置里添加
location  /  {
  auth_basic            "Restricted";
  auth_basic_user_file  htpasswd;
}
 
这里要保证 htpasswd 这个文件可以被找到。
一把保存至 /usr/local/nginx/conf/htpasswd
这个文本文件就是记录  用户名:加密密码
 
3. reload nginx
 
 
作者 stallman

相关内容

    暂无相关文章