首页 > 系统相关 >LDAP应用篇(3)Nginx接入

LDAP应用篇(3)Nginx接入

时间:2024-07-17 22:29:12浏览次数:13  
标签:http log nginx 接入 etc Nginx LDAP --

实验环境: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;
}

参考资料

标签:http,log,nginx,接入,etc,Nginx,LDAP,--
From: https://www.cnblogs.com/bashenandi/p/18308428

相关文章

  • 从零手写实现 nginx-31-load balance 负载均衡介绍
    前言大家好,我是老马。很高兴遇到你。我们为java开发者实现了java版本的nginxhttps://github.com/houbb/nginx4j如果你想知道servlet如何处理的,可以参考我的另一个项目:手写从零实现简易版tomcatminicat手写nginx系列如果你对nginx原理感兴趣,可以阅读:从零......
  • 7、nginx-日志模块的格式-log_format main、access.log(访问服务器记录的日志)
    日志模块的名称:ngx_http_log_module路径:vim/etc/nginx/nginx.conf相关指令:·日志格式:log_format---nginx有非常灵活的日志模式,每个级别的配置可以有各自独立的访问日志、日志格式通过log_format命令定义··语法Syntax:log_formatname[escape=default|json]......
  • 5、nginx-主配置文件解析
    路径:vim/etc/nginx/nginx.conf · CoreModule-核心模块(进程数等):全局/核心块:配置影响nginx全局的指令、一般运行nginx服务器的用户组、nginx进程pid存放的路径、日志存放的路径、配置文件引入、允许生成workerprocess数等CoreModule-核心模块(进程数等)12usern......
  • Nginx、LNMP万字详解
    目录Nginx特点Nginx安装添加Nginx服务Nginx配置文件全局配置HTTP配置状态统计页面Nginx访问控制授权用户授权IP虚拟主机基于域名测试基于IP测试基于端口测试LNAMP解析方式LNMP转发php-fpm解析Nginx代理LAMP解析LNMP部署示例实验环境MariaDB修改密码......
  • centos7 安装nginx
    一.安装必要的依赖yuminstallgcc-c++-yyuminstall-yopensslopenssl-develyuminstall-yzlibzlib-develyuminstall-ypcrepcre-devel二.下载nginx安装包进入usr/local里面创建nginx文件,方便后期删除干净cd/usr/localmkdirnginxcdnginxwget下载安装包w......
  • Ingress Nginx集成进Skywalking
    注:本文使用的环境为:k3sversionv1.29.5+k3s1IngressNginxcontrollerv1.10.1Skywalking9.7.0-066457bskywalking-nginx-luav0.6.0  本文假设你已经在ingress-nginx命名空间下安装部署了IngressNginxcontroller方案  在介绍方案之前,我们先了解一下相关的背......
  • [项目自荐] 交叉编译njs并使用Nginx搭建自由的个人网盘:vList5
    这个博客好久没有打理了,最近才想起来这篇文章是以下5篇文章的组合,希望这个免费的项目能实现他的初衷吧vList5:部署指南vList5.3全面加密,从我做起njs从入门(交叉编译)到入坟(与vList5配对)vList5+njs/moment实用与使用光猫折腾4:为光猫编译armel版本的nginx特色:使用......
  • Nginx的下载安装配置文件解析
    一、Nginx的安装1、下载安装包下载nginx-1.21.6和master包官网下载上传至服务器或者,直接用联网服务器下载都行,我这里使用的是虚拟机连接外网直接下载wgethttp://nginx.org/download/nginx-1.21.6.tar.gzwgethttps://github.com/arut/nginx-rtmp-module/archive/master.z......
  • 从零手写实现 nginx-29-try_files 指令
    前言大家好,我是老马。很高兴遇到你。我们为java开发者实现了java版本的nginxhttps://github.com/houbb/nginx4j如果你想知道servlet如何处理的,可以参考我的另一个项目:手写从零实现简易版tomcatminicat手写nginx系列如果你对nginx原理感兴趣,可以阅读:从零......
  • 关于静态文件目录与模板引用和Nginx location块的适配设置
    项目配置文件内关于静态文件的设置项#静态文件的URL前缀STATIC_URL='/static/'#项目根目录的静态文件目录STATICFILES_DIRS=[os.path.join(BASE_DIR,'static'),os.path.join(BASE_DIR,'parallel/static'),os.path.join(BASE_DIR,'blog/static&#......