以下是一个简单的目录上下文配置
<Directory /root/apache2/doc>
AuthType Basic
AuthName Document
AuthUserFile /root/apache2/auth/passwd
Require user rote
</Directory>
上面是通过AuthUserType指定的用户信息文件,还可通过下面两种方式设置授权,效果同上
一、用户文件
<AuthnProviderAlias file pwdfile>
AuthUserFile /root/apache2/auth/passwd
</AuthnProviderAlias>
<Directory /root/apache2/doc>
AuthType Basic
AuthName Document
AuthBasicProvider pwdfile
Require user rote
</Directory>
二、LDAP
<AuthnProviderAlias ldap ldap1>
AuthLDAPBindDN cn=rote,o=ctx
AuthLDAPBindPassword 123
AuthLDAPURL ldap://ldap.host/o=ctx
</AuthProviderAlias>
<AuthnProviderAlias ldap ldap2>
AuthLDAPBindDN cn=rote,o=dev
AuthLDAPBindPassword 123
AuthLDAPURL ldap://other.ldap.host/o=dev?cn
</AuthProviderAlias>
<Directory /webpages/secure>
AuthBasicProvider ldap1 ldap2
AuthType Basic
AuthName LDAP
Require valid-user
</Directory>