一、下载模块包
git clone https://github.com/kvspb/nginx-auth-ldap.git
二、nginx编译安装的时候,把模块编译进去。
./configure --add-module=path_to_http_auth_ldap_module
make install
三、在nginx主配置文件的http标签中添加如下代码
group_attribute People 这个是验证的时候,访问哪个组
http {
    ldap_server test2 {
        url ldap://172.16.6.13:389/DC=ptmind,DC=com?cn?sub?(objectClass=person);
        binddn "cn=ldap,dc=ptmind,dc=com";
        binddn_passwd xxxxxxxxx;
        group_attribute People;
        group_attribute_is_dn on;
        require valid_user;
    }
}
四、然后再起一个可以访问的server进行验证
server {
    listen 8000;
    server_name localhost;
    location / {
        root html;
        index index.html index.htm;
        auth_ldap "Forbidden";
        auth_ldap_servers test2;
    }
}
五、验证结果如下

33