好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

nginx HttpAuthBasicModule身份认证配置auth_basic - Linux操


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

查看更多关于nginx HttpAuthBasicModule身份认证配置auth_basic - Linux操的详细内容...

  阅读:52次