LDAP应用篇(3)Nginx接入

LDAP应用篇(3)Nginx接入

实验环境:Oracle Linux R8

在搞Nginx比较错愕的是,居然 Nginx 并未内置对LDAP的支持,需要单独编译。然而 yum 安装的 nginx 并不支持导入模块,不得不再次温习一下编译安装 Nginx 的路数了。

下载组件

github 中下载组件的源代码:

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

部署Nginx

环境准备
yum install openssl openssl-devel pcre-devel make autoconf gcc gcc-c++ -y
编译
./configure  --user=nginx --group=nginx --prefix=/etc/nginx \
--error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log \
--with-http_ssl_module --with-http_v2_module --with-http_addition_module \
--with-http_gzip_static_module --with-http_random_index_module \
--add-module=/root/soft/nginx-auth-ldap

要注意的是,这里的编译,是编译nginx而不是组件本身。编译后的返回路径提示为:

nginx path prefix: "/etc/nginx"
nginx binary file: "/etc/nginx/sbin/nginx"
nginx modules path: "/etc/nginx/modules"
nginx configuration prefix: "/etc/nginx/conf"
nginx configuration file: "/etc/nginx/conf/nginx.conf"
nginx pid file: "/etc/nginx/logs/nginx.pid"
nginx error log file: "/var/log/nginx/error.log"
nginx http access log file: "/var/log/nginx/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
配置

Nginx 的主配置文件的 http 指令中,添加下面的配置段:

ldap_server test1 {
  url ldaps://server.example.com:636/dc=example,dc=com?uid?sub?(objectClass=*);
  binddn "cn=admin,dc=example,dc=com";
  binddn_passwd "123456";
   memberuid;
  group_attribute_is_dn on;
  require valid_user;
}

上面这段配置没有太闹明白其含义,比如 group_attribute 的值组件的文档中用的是 uniquemember,而一般能搜到的文章都是用的 memberuid ,根据对属性的反复对比,这应该就是默认的过滤配置,及具备了该组属性的用户方可登入。当然这也只是猜测,没有看到明确的说明出处!

根据常规对 Nginx 的管理,至少可以判断出上面的块配置,相当于定义了一个指令,因此可以在后面的相应位置,比如 server 或者 location 指令中进行配置,如果在同一个 server 指令范围内都进行了引用,则后者会覆盖前者的配置:

server {
    auth_ldap "Forbidden";
    auth_ldap_servers test1;
}

参考资料

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

雨帝夜泪

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值