nginx 引入LDAP验证

1、下载模块包
git clone https://github.com/kvspb/nginx-auth-ldap.git
2、nginx编译安装的时候,把模块编译进去。
./configure --add-module=path_to_http_auth_ldap_module
make install
3、在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;
    }
}
4、而后再起一个能够访问的server进行验证
server {
    listen 8000;
    server_name localhost;
    location / {
        root html;
        index index.html index.htm;
        auth_ldap "Forbidden";
        auth_ldap_servers test2;
    }
}
5、验证结果以下

33

相关文章
相关标签/搜索