nginx 引入LDAP驗證

一、下載模塊包
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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章