【问题标题】:Apache LDAP Authentication only for some virtualhostsApache LDAP 身份验证仅适用于某些虚拟主机
【发布时间】:2018-01-15 18:16:21
【问题描述】:

我有一个在 CentOS 7 下运行 Apache 2.4.6 的网络服务器,其中有几个网络资源。我只想对其中一些应用 LDAP 身份验证,因此我尝试通过为每个资源创建一个虚拟主机并将 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文件的相关信息:

ServerRoot "/etc/httpd"
Listen 80
Include conf.modules.d/*.conf
User apache
Group apache

<Directory />
AllowOverride none
Require all denied
</Directory>

<Directory "/var/www">
AllowOverride None
Require all granted
</Directory>

<IfModule dir_module>
DirectoryIndex index.html
</IfModule>

IncludeOptional conf.d/*.conf

但它总是要求对 test1 和 test2 进行身份验证,而对于 test2,我什至无法在登录后加载内容(test1 加载正常)。

【问题讨论】:

    标签: apache centos virtualhost


    【解决方案1】:

    最后通过使用Alias指令实现,所以:

    /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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-10-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-27
      • 2016-02-18
      • 2013-12-19
      相关资源
      最近更新 更多