2017-08-08 50 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