指定包含 conf 文件时 Apache Conf 失败

指定包含 conf 文件时 Apache Conf 失败

我有一个 drupal 多站点安装,运行良好。自从我设置它以来,这个问题一直困扰着我,我正在努力找出为什么它不起作用。

当我重新加载 apache 时,如果取消注释“Include conf.d/ip.conf”行,则会出现以下错误:

allow not allowed here
   ...fail!

如果我指定如下所示的 IP 地址(它们现在已被注释),它就可以工作了!

如有任何建议或帮助我将不胜感激(显然这些 IP 地址不是我正在使用的)。

<Directory "/home/d/r/drupal/web/public_html">
    AllowOverride none

    # Define file limitations on drupal files
    <FilesMatch "(install.php|cron.php|update.php|\.txt)$">
        Order deny,allow
#=================================================================
# THIS DOES NOT WORK? I GET AN ERROR RESTARTING APACHE FOR IP.CONF
        Include conf.d/ip.conf
#=================================================================
# SO I MANUALLY ADD THE IP ADDRESSES HERE:
#Allow from 123.123.123.123
#Allow from 222.222.222.222
#Allow from 555.555.555.555
        Deny from all
    </FilesMatch>

   <FilesMatch "robots.txt">
      Allow from all
   </FilesMatch>

    # Read in Drupal default .htaccess file asif conf - easier CVS management
    Include /home/d/r/drupal/web/public_html/.htaccess

        # Offline mode for multisite setup - see file for more info
        # Uncomment the line below to set sites offline
    # Include conf.d/offline.conf

</Directory>

# Sorry, no svn peeking
<DirectoryMatch "\.svn">
    # Currently pointing back to drupal
    # High traffic sites might want custom
    # error pages, no need to load drupal
    ErrorDocument 403 /index.php
    Order allow,deny
    Deny from all
    Satisfy All
</DirectoryMatch>

# Allow the .htacces files to be used in the sites folder where /files are stored
<Directory "/home/d/r/drupal/web/public_html/sites">
    AllowOverride
</Directory>

ip.conf 如下所示:

Allow from 123.123.123.123
Allow from 222.222.222.222
Allow from 555.555.555.555

答案1

导致此问题的原因是 apache2.conf 加载了 conf.d 中的所有文件(包括 conf.d/*),这意味着 ip.conf 加载到了错误的位置。这意味着语句的allow from处理脱离了上下文。

相关内容