nginx 支持ldap

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

yum -y install openldap-devel

一、下载模块包
git clone https://github.com/kvspb/nginx-auth-ldap.git
二、nginx编译安装的时候,把模块编译进去。
./configure --add-module=path_to_http_auth_ldap_module
make install

如果报错openssl版本低,则升级openssl版本
如果报pragma GCC diagnostic 选项未知

gcc 4.4无法解释'#pragma GCC诊断警告“-Wcpp”'

修复如下。

// make sure manual warnings don't get escalated to errors
#ifdef clang
#pragma clang diagnostic warning "-W#warnings"
#else
#ifdef GNUC
#if GNUC > 4
#pragma GCC diagnostic warning "-Wcpp"
#endif
#endif
#endif
// TODO: do the same stuff for MSVC and/or other compiler
加一个if判断,就行了

二.配置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;

  }

}

进入conf.d 设置:

server {

   location /status {

        stub_status on;

        access_log off;

        auth_ldap "Restricted Space";

        auth_ldap_servers openldap;

    }

}

在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;
}
}

转载于:https://blog.51cto.com/10643230/2333495

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值