Nginx - LDAP Authentication

Nginx - Basic Authentication稍微高级一点点的LDAP认证。

Install http_auth_request_module

sudo ./configure --with-http_stub_status_module --with-http_ssl_module --with-http_auth_request_module
sudo make
sudo make install

$ sudo nginx -V
nginx version: nginx/1.16.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled
configure arguments: --with-http_stub_status_module --with-http_ssl_module --with-http_auth_request_module

Install python-ldap

I download and install offline.

# sudo yum install python-ldap
sudo rpm -hvi python-ldap-2.4.15-2.el7.x86_64.rpm

# sudo yum install openldap-devel
# cyrus-sasl-devel is dependency package
sudo rpm -hvi cyrus-sasl-devel-2.1.26-23.el7.x86_64.rpm
sudo rpm -hvi openldap-devel-2.4.44-21.el7_6.x86_64.rpm

Nginx Configure

Download package from https://github.com/nginxinc/nginx-ldap-auth

Use sample configure.

cp /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf_bak
cp nginx-ldap-auth.conf /usr/local/nginx/conf/nginx.conf
sudo nginx -t
sudo nginx -s reload

The listen port is 8081 in the sample configure.
We need to change/open the port and use correct LDAP configure for test.

Startup LDAP Daemon

Run python below to start the daemon and sample app.

  • nginx-ldap-auth-daemon.py
  • backend-sample-app.py

Can use the following bash to start the daemon.

nginx-ldap-auth-daemon-ctl-rh.sh start
nginx-ldap-auth-daemon-ctl-rh.sh stop
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值