之前在ldap的文章里有提到NGINX结合ldap认证一些公共服务的时候,会非常方便,那么如何将我们需要的ldap模块儿添加到部署好了的openresty中呢,这篇文章就来讲解一下。
1,下载相关包
如果之前安装之后,删除了安装包,现在找不到了,那么可以从如下网站下载与当前一致的版本。
wget https://openresty.org/download/openresty-1.13.6.2.tar.gz
下载所需的ldap模块儿,项目地址为:https://github.com/kvspb/nginx-auth-ldap.git 考虑到不好下载,于是直接在国内同步了一份。
cd /opt # 注意拉取代码存放位置
git clone https://gitee.com/eryajf/nginx-auth-ldap.git
接下来就进入正式的编译安装了。
2,安装依赖
yum -y install gcc gcc-c++ pcre pcre-devel openldap-devel lua-devel systemtap-sdt-devel openssl-devel openssl
3,进行编译
需要注意编译并不能在openresty根目录进行,否则将会失败。
tar xf openresty-1.13.6.2.tar.gz
cd openresty-1.13.6.2/bundle/nginx-1.13.6/
然后再进行编译:
./configure --prefix=/usr/local/openresty/nginx --with-cc-opt='-O2 -DNGX_LUA_ABORT_AT_PANIC -I/usr/local/openresty/zlib/include -I/usr/local/openresty/pcre/include -I/usr/local/openresty/openssl/include' --add-module=../ngx_devel_kit-0.3.0 --add-module=../echo-nginx-module-0.61 --add-module=../xss-nginx-module-0.06 --add-module=../ngx_coolkit-0.2rc3 --add-module=../set-misc-nginx-module-0.32 --add-module=../form-input-nginx-module-0.12 --add-module=../encrypted-session-nginx-module-0.08 --add-module=../srcache-nginx-module-0.31 --add-module=../ngx_lua-0.10.13 --add-module=../ngx_lua_upstream-0.07 --add-module=../headers-more-nginx-module-0.33 --add-module=../array-var-nginx-module-0.05 --add-module=../memc-nginx-module-0.19 --add-module=../redis2-nginx-module-0.15 --add-module=../redis-nginx-module-0.3.7 --add-module=../ngx_stream_lua-0.0.5 --with-ld-opt='-Wl,-rpath,/usr/local/openresty/luajit/lib -L/usr/local/openresty/zlib/lib -L/usr/local/openresty/pcre/lib -L/usr/local/openresty/openssl/lib -Wl,-rpath,/usr/local/openresty/zlib/lib:/usr/local/openresty/pcre/lib:/usr/local/openresty/openssl/lib' --with-pcre-jit --with-stream --with-stream_ssl_module --with-http_v2_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-http_stub_status_module --with-http_realip_module --with-http_addition_module --with-http_auth_request_module --with-http_secure_link_module --with-http_random_index_module --with-http_gzip_static_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-threads --with-file-aio --with-dtrace-probes --with-http_image_filter_module --with-stream --with-stream_ssl_module --with-http_ssl_module --add-module=/opt/nginx-auth-ldap
注意如上步骤,如果在一个已经安装过openresty的环境中新增,则需要先把原来的安装包移走
,不然下边make的时候会报如下错误:
/bin/ld: warning: libssl.so.10, needed by /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libldap.so, may conflict with libssl.so.1.1
/bin/ld: objs/src/event/ngx_event_openssl.o: undefined reference to symbol 'SSL_CTX_get_ex_new_index@@libssl.so.10'
/usr/lib64/libssl.so.10: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[1]: *** [objs/nginx] Error 1
make[1]: Leaving directory `/usr/local/src/openresty-1.13.6.2/bundle/nginx-1.13.6'
make: *** [build] Error 2
安装:
make
make install
安装完成之后,重新软链一下nginx的主程序,就可以投入使用了。
ln -snf /usr/local/openresty/nginx/sbin/nginx /usr/sbin/
4,配置参考
具体NGINX配置ldap认证,可以参考如下文章:
↓
↓
↓
openLDAP学习笔记–集成zabbix,Jenkins,Gitlab,jumpserver,harbor,NGINX实战 |坐而言不如起而行! 二丫讲梵
网上有很多文章,都是在介绍了部署之后,就完事儿了,真正系统认真地把实际应用场景中的配置内容分享的,则是少之又少,有分享的,也都是含糊不清,让人难以学习,这里我特别将日常生产中常用的一些软件配置方式,一一过了一遍,并整理分享,愿阅读本篇文章的你能有所收获。 另外,我所分享出来的,可能只是我个人的一种思路方案,如果您有更加简便合理的方案,欢迎留言分享交流! 1,zabbix配置LDAP zabbix在配置起来是比较简单的,我们直接使用

扫码订阅本站,第一时间获得更新
微信扫描二维码,订阅我们网站的动态,另外不定时发送WordPress小技巧,你可以随时退订,欢迎订阅哦~