152

我正进入(状态

[2012 年 4 月 24 日星期二 12:12:55] [错误] [客户端 127.0.0.1] 客户端被服务器配置拒绝:/labs/Projects/Nebula/bin/

我的目录结构看起来像(我使用的是 Symfony 2,应该是其他 Web 框架的类似结构)

在此处输入图像描述

我的虚拟主机设置如下:

<VirtualHost nebula:80>
    DocumentRoot "/labs/Projects/Nebula/web/"
    ServerName nebula
    ErrorLog "/var/log/httpd/nebula-errors.log"
</VirtualHost>

<Directory "/labs/Projects/Nebula/">
    Options All
    AllowOverride All
    Order allow,deny
    Allow from 127.0.0 192.168.1 ::1 localhost
</Directory>

我想知道是什么问题,我该如何解决?

4

9 回答 9

400

Apache 2.4.3 (or maybe slightly earlier) added a new security feature that often results in this error. You would also see a log message of the form "client denied by server configuration". The feature is requiring an authorized user identity to access a directory. It is turned on by DEFAULT in the httpd.conf that ships with Apache. You can see the enabling of the feature with the directive

Require all denied

This basically says to deny access to all users. To fix this problem, either remove the denied directive (or much better) add the following directive to the directories you want to grant access to:

Require all granted

as in

<Directory "your directory here">
   Order allow,deny
   Allow from all
   # New directive needed in Apache 2.4.3: 
   Require all granted
</Directory>
于 2012-12-17T22:46:57.067 回答
10

好的,我使用了错误的语法,我应该使用

Allow from 127.0.0.1
Allow from ::1
...
于 2012-05-04T03:18:08.420 回答
5

In Apache 2.4 the old access authorisation syntax has been deprecated and replaced by a new system using Require.

What you want then is something like the following:

<Directory "/labs/Projects/Nebula/">
  Options All
  AllowOverride All
  <RequireAny>
    Require local
    Require ip 192.168.1
  </RequireAny>
</Directory>

This will allow connections that originate either from the local host or from ip addresses that start with "192.168.1".

如果您不想立即更新配置,还有一个新模块可以让 Apache 2.4 识别旧语法:

sudo a2enmod access_compat
于 2015-05-20T08:36:50.117 回答
2

我在使用 Vesta CP 时遇到了这个问题,对我来说,诀窍是删除 .htaccess 并尝试再次访问任何文件。

这导致 .htaccess 文件的重新生成,然后我能够访问我的文件。

于 2016-01-21T13:06:59.193 回答
1

您可以尝试将“Allow from 127.0.0 192.168.1 ::1 localhost”更改为“Allow from all”。如果这样可以解决您的问题,您需要减少对可以从何处请求内容的限制

于 2012-05-02T05:32:31.783 回答
1

这是我在 debian 上的 symfony 1.4 虚拟主机文件,它运行良好。

  <Directory /var/www/sf_project/web/>
    Options All Indexes FollowSymLinks    
    AllowOverride All
    Order allow,deny
    Allow from all
  </Directory>

如果您不想限制对特定 IP 范围的访问,例如 localhost,请使用以下命令:

Allow from 127.0.0.0/8

The mod_authz_host is responsible for filtering ip ranges. You can look up detailed things in there.

But maybe the problem could be related to some kind of misconfiguration in your "apache2.conf".

On what OS is the apache running?

于 2012-05-06T13:05:17.647 回答
1

if you are having the

Allow from All

in httpd.conf then make sure us have

index.php

like in the below line in httpd.conf

DirectoryIndex index.html index.php
于 2014-09-20T05:29:12.720 回答
0

In my case the key was:

AllowOverride All

in vhost definition. I hope it helps someone.

于 2015-04-27T22:52:33.160 回答
-4

这段代码对我有用..

 <Location />
Allow from all
Order Deny,Allow
</Location> 

希望这对其他人有帮助

于 2015-07-27T12:21:23.107 回答