Apache LDAP认证
Apache LDAP认证是使用基于LDAP目录的用户身份验证来保护Apache Web服务器的一种方法。以下是一个使用基本LDAP身份验证的简单示例:
sudo apt-get install libapache2-mod-authnz-ldap
sudo a2enmod authnz_ldap
在Apache配置文件中添加以下内容:
AuthType Basic
AuthName “LDAP Auth”
AuthBasicProvider ldap
AuthLDAPURL “ldap://ldap.server.hostname:389/ou=users,dc=example,dc=com?uid”
AuthLDAPBindDN “cn=ldapadmin,dc=example,dc=com”
AuthLDAPBindPassword xxxxx
Require valid-user
其中,AuthLDAPURL 是LDAP服务器的URL和基本情况下查询的LDAP属性。AuthLDAPBindDN 和 AuthLDAPBindPassword 是连接LDAP服务器所需的凭据。
sudo service apache2 restart
现在,任何试图访问受保护目录的用户都将被重定向到LDAP服务器进行身份验证。如果提供的凭据是有效的,则允许访问。