nginx认证走LDAP
发表于:2025-12-02 作者:千家信息网编辑
千家信息网最后更新 2025年12月02日,使用nginx走ldap认证:将原nginx进行备份:[root@daya-02 nginx-1.12.2]# mv /usr/sbin/nginx /usr/sbin/nginx.bak[root@
千家信息网最后更新 2025年12月02日nginx认证走LDAP
使用nginx走ldap认证:
将原nginx进行备份:
[root@daya-02 nginx-1.12.2]# mv /usr/sbin/nginx /usr/sbin/nginx.bak[root@daya-02 nginx-1.12.2]# cp -r /etc/nginx/ /etc/nginx_bak
查看当前安装好的nginx版本:
[root@daya-02 ~]# nginx -Vnginx version: nginx/1.12.2
下载相同版本的源码包:
[root@daya-02 ~]# wget http://nginx.org/download/nginx-1.12.2.tar.gz[root@daya-02 ~]# tar xf nginx-1.12.2.tar.gz
下载ldap需要的扩展包:
git clone https://github.com/kvspb/nginx-auth-ldap.git
查看原nginx的编译参数:
[root@daya-02 nginx-1.12.2]# nginx -Vnginx version: nginx/1.12.2built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)built with OpenSSL 1.0.2k-fips 26 Jan 2017TLS SNI support enabledconfigure arguments: --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_auth_request_module --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-google_perftools_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' --with-ld-opt='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E'
再次编译就需要原来的编译参数加上需要添加的参数就好:
[root@daya-02 nginx-1.12.2]# ./configure --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_auth_request_module --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-google_perftools_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' --with-ld-opt='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E' --add-module=/root/nginx-auth-ldap
然后执行make,只make就好不用install
检查是否可用:
[root@daya-02 nginx-1.12.2]# ./objs/nginx -t
进行替换:
[root@daya-02 nginx-1.12.2]# cp ./objs/nginx /usr/sbin/
重启:
[root@daya-02 nginx-1.12.2]# nginx -s reload
配置ldap认证:
ldap_server test { url ldap://172.16.28.180:389/DC=test,DC=com?cn?sub?(objectClass=person); binddn "cn=admin,dc=test,dc=com"; binddn_passwd 123465; #group_attribute People; #group_attribute_is_dn on; require valid_user; } server { listen 8080; server_name _; root /usr/share/nginx/html; location / { auth_ldap "Forbidden"; auth_ldap_servers test; } }遇到问题:以下都是环境上缺少相关的依赖,安装即可
./configure: error: the HTTP XSLT module requires the libxml2/libxsltyum install libxslt-devel -y./configure: error: the HTTP image filter module requires the GD library. yum install gd-devel -y ./configure: error: perl module ExtUtils::Embed is required yum -y install perl-devel perl-ExtUtils-Embed ./configure: error: the GeoIP module requires the GeoIP library. yum -y install GeoIP GeoIP-devel GeoIP-data ./configure: error: the Google perftools module requires the Google perftoolsyum install gperftools -y./configure: error: SSL modules require the OpenSSL library.yum -y install openssl openssl-develchecking for --with-ld-opt="-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E" ... not found./configure: error: the invalid value in --with-ld-opt="-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E"yum install redhat-rpm-config -y./configure: error: perl module ExtUtils::Embed is requiredyum -y install perl-devel perl-ExtUtils-Embed在执行make时候的报错:/root/nginx-auth-ldap/ngx_http_auth_ldap_module.c:33:18: fatal error: ldap.h: No such file or directory #includeyum install -y openldap-devel
参数
编译
认证
版本
相同
再次
备份
好不
时候
源码
环境
问题
装好
检查
配置
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
长沙交易性数据库
山德希尔数据库
哪个地方找软件开发好找
求生之路创建服务器
服务器里面有意思的指令
db数据库注入
迷你怎么弄服务器账号
数据库字段名对应的类型
修补软件开发
网络安全实训机构
企业如何进入当地企业数据库
商丘市网络安全课堂收费吗
数据库机房监测管理系统软著
如何注册路由器服务器
域名换服务器以后要备案吗
30岁学软件开发晚吗
手机连接服务器异常
阿里数据库开发手册
辽阳运和软件开发有限公司招聘
山东网络时间同步服务器云主机
数据库数据论文
花都网络安全运维哪个品牌好
网络安全密锁是多少
南京玄武网络技术学院
智能网络技术概念股票
小白测评电池数据库官网
海康服务器显示摄像头预览异常
移动光猫服务器端口是什么
谷歌服务器未受保护
武汉信息网络安全协会