nginx 搭建LDAP认证

一.添加nginx-auth-ldap nginx模块

编译nginx-auth-ldap模块需要ldap.h头文件,所以需要先安装ldap库

yum -y install openldap-devel

在编译nginx时,添加上模块编译参数,如

cd /usr/local/src

git clone https://github.com/kvspb/nginx-auth-ldap.git

--add-module=/usr/local/src/nginx-auth-ldap

二.配置ldap认证

http {

        ldap_server openldap {

        url ldap://192.168.192.20:389/dc=example,dc=com?uid?sub?(&(objectClass=account));

        binddn "cn=Manager,dc=example,dc=com";

        binddn_passwd "secret";

        group_attribute memberuid;

        group_attribute_is_dn on;

        require valid_user;

      }

}

server {

       location /status {

            stub_status on;

            access_log off;

            auth_ldap "Restricted Space";

            auth_ldap_servers openldap;

        }

}

你可能感兴趣的:(Nginx)