尝试debian-9.13.0-amd64下apache和proftpd用openldap整合按组认证笔记之五:apache配置openldap组认证、h5ai、关闭PHP解析

本文记录了在Debian 9.13.0系统下,Apache如何配置OpenLDAP进行组认证,并实现与h5ai的集成,同时关闭PHP解析。主要步骤包括激活mod_authnz_ldap模块,配置Apache的.htaccess文件,解决Apache 2.4的配置变化,以及处理多用户组情况。通过这些设置,实现了基于组的权限管理和美观的目录索引界面。
摘要由CSDN通过智能技术生成

感觉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
<
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值