Apache: client denied by server configuration

I am getting

[Tue Apr 24 12:12:55 2012] [error] [client 127.0.0.1] client denied by server configuration: /labs/Projects/Nebula/bin/

My directory structure looks like (I am using Symfony 2, should be similar structure for other web frameworks)

enter image description here

I have vhosts setup like:

<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>

I wonder whats the problem and how do I fix it?


Solution 1:

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>

Solution 2:

OK I am using the wrong syntax, I should be using

Allow from 127.0.0.1
Allow from ::1
...

Solution 3:

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".

There is also a new module available that makes Apache 2.4 recognise the old syntax if you don't want to update your configuration right away:

sudo a2enmod access_compat