2017-08-08 49 views
0

我有一个在CentOS 7下运行Apache 2.4.6的webserver,其中有几个Web资源。我只想对其中的一些应用LDAP认证,所以我试图通过为每个资源创建一个虚拟主机并仅将LDAP认证配置为我想要的资源来实现。仅适用于某些虚拟主机的Apache LDAP身份验证

这是我的尝试:

/etc/httpd/conf.d/test1.conf:

<VirtualHost *:80> 
Servername server_name 
DocumentRoot /var/www/html/test1 

<Directory "/var/www/html/test1"> 
Options FollowSymLinks 
AllowOverride None 
Order allow,deny 
Allow from all 

#LDAP 
SetHandler php-script 
Require all denied 
AuthBasicProvider ldap 
AuthUserFile /dev/null 
AuthName "ldap_auth" 
AuthType Basic 
AuthLDAPURL ldap_url 
AuthLDAPBindDN ldap_dn 
AuthLDAPBindPassword ldap_pass 
Require ldap-group ldap_group 

</Directory> 
</VirtualHost> 

/etc/httpd/conf.d/test2.conf:

<VirtualHost *:80> 
    Servername server_name 
    DocumentRoot /var/www/html/test2 

    <Directory "/var/www/html/test2"> 
    Options FollowSymLinks 
    AllowOverride None 
    Order allow,deny 
    Allow from all 
    </Directory> 
</VirtualHost> 

这是我目前的httpd.conf文件的相关信息:

​​

但它总是要两个TEST1和TEST2身份验证和测试2我甚至无法加载登录(test1的加载罚款)后的内容。

回答

0

最后通过别名指令,所以实现:

/etc/httpd/conf.d/test1.conf:

<VirtualHost *:80> 
Servername server_name 
DocumentRoot /var/www/html/test1 

Alias /test1 /var/www/html/test1 
<Directory "/var/www/html/test1"> 
Options FollowSymLinks 
AllowOverride None 
Order allow,deny 
Allow from all 

#LDAP 
SetHandler php-script 
Require all denied 
AuthBasicProvider ldap 
AuthUserFile /dev/null 
AuthName "ldap_auth" 
AuthType Basic 
AuthLDAPURL ldap_url 
AuthLDAPBindDN ldap_dn 
AuthLDAPBindPassword ldap_pass 
Require ldap-group ldap_group 

</Directory> 
</VirtualHost> 

/etc/httpd/conf.d /test2.conf:

<VirtualHost *:80> 
Servername server_name 
DocumentRoot /var/www/html/test2 

Alias /test2 /var/www/html/test2 
<Directory "/var/www/html/test2"> 
Options FollowSymLinks 
AllowOverride None 
Order allow,deny 
Allow from all