感觉proftpd对openldap的支持已经有点过时了,2013年以后就再没更新了
https://github.com/proftpd/mod_ldap
居然还必须用posixGroup/gidNumber/memberUid的组合,配置为openldap组认证的文章在网上也特别难找。
而apache对openldap的支持要好的多,也是最简单的,相关文章一搜一大把,于是把这篇笔记放在前面
主要参考文章(下一篇proftpd配置openldap组认证也是参考这个法国网站的另一篇文章)
1、http://bouthors.fr/wiki/doku.php?id=en:linux:serveur_web:auth
这篇文章是apache 2.2的,在apache 2.4 上会有一些配置方法小变动
一、激活apache的mod_authnz_ldap模块,完成后需要重启apache2
root@mydebian210:~# a2enmod ldap authnz_ldap
Enabling module ldap.
Considering dependency ldap for authnz_ldap:
Module ldap already enabled
Enabling module authnz_ldap.
To activate the new configuration, you need to run:
systemctl restart apache2
root@mydebian210:~# systemctl restart apache2
从终端输出可以看出stretch中的apache 2.4缺省已可用mod_ldap模块,实际激活的mod_authnz_ldap模块才是用于认证的
apache 2.4中的mod_ldap模块并不是用于认证的(虽然和proftpd中用于认证的模块mod_ldap名字完全一样)
https://httpd.apache.org/docs/2.4/mod/mod_ldap.html
https://httpd.apache.org/docs/2.4/mod/mod_authnz_ldap.html
二、配置主目录允许用目录中的.htaccess覆盖主配置文件中认证方面的设置
nano /etc/apache2/apache2.conf
#<Directory /var/www/>
# Options Indexes FollowSymLinks
# AllowOverride None
# Require all granted
#</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride AuthConfig
Require all granted
</Directory>
重启apache
# apachectl configtest
Syntax OK
# systemctl restart apache2
三、配置.htaccess文件,把index.html改名以免影响autoindex,开始测试
以后的测试都不会用到testgroup,而是以testgroup2为模板,因为testgroup的基类中没有加入posixGroup,
将来是无法与proftpd的openldap组认识进行整合的
# mv /var/www/html/index.html /var/www/html/default.html
# mkdir -p /var/www/html/doc_private
# cd /var/www/html/doc_private
# nano .htaccess
配置.htaccess内容抄的参考文章一
AuthName "Please Input Your Password"
AuthType Basic
AuthBasicProvider ldap
AuthLDAPURL ldap://localhost/dc=mydebian210,dc=mydomain,dc=net?uid
AuthLDAPBindDN "cn=admin,dc=mydebian210,dc=mydomain,dc=net"
AuthLDAPBindPassword "secret_password"
AuthzLDAPAuthoritative on
#OK Require ldap-user testuser
#Satisfy any
Require ldap-group cn=testgroup2,ou=web_ftp_groups,dc=mydebian210,dc=mydomain,dc=net
测试访问http://10.16.97.210目录中只显示default.html,没有看到doc_private目录,
测试访问http://10.16.97.210/doc_private/,报 500 Internal Server Error错误
查看/var/log/apache2/error.log最后几行,其中有出错信息如下
[Tue Oct 20 21:08:34.283390 2020] [core:alert] [pid 1521] [client 10.16.97.100:62005] /var/www/html/doc_private/.htaccess: Invalid command 'AuthzLDAPAuthoritative', perhaps misspelled or defined by a module not included in the server configuration
<