我知道如何在apache2中通过LDAP授权用户:
# put the following in the VirtualHost
<VirtualHost *:443>
ServerAdmin user1@bar.foo.com
DocumentRoot /var/www
<Directory />
AuthType Basic
AuthName "Please provide USERNAME AND PASSWORD"
AuthBasicProvider ldap
Order allow,deny
Allow from all
AuthLDAPURL "ldaps://ehh.foo.com/ou=ehh,o=foo.com?mail"
Require valid-user
Require ldap-attribute emailAddress=someuser@bar.foo.com
问:但我们需要使用nginx.我们如何通过LDAP将nginx配置为auth?
使用Ubuntu 12.04.5
解决方法:
为此,您需要下载/克隆,编译和安装nginx-auth-ldap
您可以下载zip文件:
wget https://github.com/kvspb/nginx-auth-ldap/archive/master.zip
unzip master.zip
然后cd到你的nginx源文件夹并执行:
./configure --add-module=~-/nginx-auth-ldap-master
sudo make install
之后你可以配置nginx:
http {
ldap_server test1 {
url ldap://192.168.0.1:3268/DC=test,DC=local?sAMAccountName?sub?(objectClass=person);
binddn "TEST\\LDAPUSER";
binddn_passwd LDAPPASSWORD;
group_attribute uniquemember;
group_attribute_is_dn on;
require valid_user;
}
ldap_server test2 {
url ldap://192.168.0.2:3268/DC=test,DC=local?sAMAccountName?sub?(objectClass=person);
binddn "TEST\\LDAPUSER";
binddn_passwd LDAPPASSWORD;
group_attribute uniquemember;
group_attribute_is_dn on;
require valid_user;
}
}
server {
listen 8000;
server_name localhost;
auth_ldap "Forbidden";
auth_ldap_servers test1;
auth_ldap_servers test2;
location / {
root html;
index index.html index.htm;
}
}
如模块文档中所示.