当我试图通过浏览器访问localhost时,我得到这个错误。

AH01630: client denied by server configuration

我检查了我的网站文件夹权限使用:

sudo chmod 777 -R *

这是我的配置文件:

<VirtualHost *:80>
ServerAdmin webmaster@localhost

DocumentRoot /home/user-name/www/myproject
<Directory />
    Options FollowSymLinks
    AllowOverride all
    Allow from all
</Directory>

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

<Directory  /home/user-name/www/myproject/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
    Order allow,deny
    Allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
    AllowOverride all
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride all
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>


当前回答

问题出在VirtualHost中,但可能不是

要求全部批准

确认您的配置是正确的,下面是正确的示例

其他回答

这个“bug”实际上是Apache 2.4的新常态。在我的例子中,我有一个非常具体的规则,拒绝访问任何名称以“。”开头的文件夹或文件,因此我必须为需要这种奇怪名称的特定公用文件夹设置一个异常。

声明一下,我的重写规则是:

RewriteRule”(? ! \ .trusted)(^ | /) \”。- [F]

这条规则[F]删除了所有以“。”开头的东西,但是。trusted,多亏了正则表达式“?!”否定的魔力。

对我来说,我实际上已经根据2.4标准更新了允许和拒绝规则。

Require all granted

然而,这仍然导致我收到相同的AH01630错误。我找到了另一个线程,它建议重新安装apache2。不知何故,这奏效了!如果有人愿意解释一下,我会很有帮助的。

信用:AH01630:客户端被服务器配置拒绝,但要求设置所有授予(Apache 2.4, CentOs)

为了帮助像我一样在谷歌上搜索的人,我在试图访问服务器上的SVG文件时遇到了这个错误消息,例如https://example.com/images/file.svg。其他文件类型似乎还好,只是SVG失败了。

我在/etc/httpd conf文件中寻找,并检查了每一个要求所有拒绝类型的配置,只是找不到什么配置有这种效果。

我在VirtualHost配置中将LogLevel转换为调试,可以看到mod_authz_core日志指定有一个'Require all denied'的效果:

[Mon Jun 10 13:09:54.321022 2019] [authz_core:debug] [pid 23459:tid 140576341206784] mod_authz_core.c(817): [client 127.0.0.1:54626] AH01626: authorization result of Require all denied: denied
[Mon Jun 10 13:09:54.321038 2019] [authz_core:debug] [pid 23459:tid 140576341206784] mod_authz_core.c(817): [client 127.0.0.1:54626] AH01626: authorization result of <RequireAny>: denied
[Mon Jun 10 13:09:54.321082 2019] [authz_core:error] [pid 23459:tid 140576341206784] [client 127.0.0.1:54626] AH01630: client denied by server configuration: /home/blah/htdocs/images/file.svg

通过盲测,我将文件移动到web根目录的根目录,然后发现我可以在https://example.com/file.svg上访问它。所以它只在images文件夹失败了。这让我在images文件夹中找到了一个我完全不知道的。htaccess文件。

原来禅宗车1.5带有一个图像/。Htaccess文件有:

# deny *everything*
 <FilesMatch ".*">
   <IfModule mod_authz_core.c>
     Require all denied
   </IfModule>
   <IfModule !mod_authz_core.c>
     Order Allow,Deny
     Deny from all
   </IfModule>
 </FilesMatch>

 # but now allow just *certain* necessary files:
 <FilesMatch "(?i).*\.(jpe?g|gif|webp|png|swf)$" >
   <IfModule mod_authz_core.c>
     Require all granted
   </IfModule>
   <IfModule !mod_authz_core.c>
     Order Allow,Deny
     Allow from all
   </IfModule>
 </FilesMatch>

这是非常恼人的,我希望这可以提醒其他人检查文件系统的每一个级别的.htaccess文件,导致你有问题访问的文件,以防有这种tom愚行正在发生。

我在新服务器上设置虚拟主机时遇到了这个问题,并且站点托管在标准的/var/www/html路径之外。您需要考虑两件主要的事情(例如,假设您正在/opt/my-site中设置一个站点)

在默认的2.4安装中,会显式地拒绝访问根文件系统,然后只允许访问/var/www/html。所以你需要给web服务器从新目录读取的权限,就像这样:

<Directory /opt/mysite>
   Require all granted
</Directory>

完成此操作后,请确保虚拟主机的DocumentRoot位于上面授予访问权限的路径下的某个位置。

<VirtualHost *:80>
        ServerName neatwebsite.com
        DocumentRoot /opt/my-site/html
</VirtualHost>

当我遇到这个问题时,我已经设置好了所有的VirtualHosts,但忘记允许从目录结构中读取(所以我错过了指令)。您需要考虑这两个指令,以及它们如何协同工作。

确保包括任何特定于用户的配置!

如果这一页上的其他答案都不适合你,下面是我在几个小时的挣扎后遇到的。

我使用了特定于用户的配置,在/private/etc/apache2/extra/httpd-userdir.conf中将Sites指定为我的UserDir。但是,我被禁止访问端点http://localhost/~jwork/。

我可以在/var/log/apache2/error_log中看到对/Users/jwork/Sites/的访问被阻止。但是,我被允许通过http://localhost/访问DocumentRoot。这表明我没有权限查看~jwork用户。但据我所知,ps aux | egrep '(apache|httpd)'和lsof -i:80, apache是为jwork用户运行的,所以很明显没有使用我的用户配置编写一些东西。

给定一个名为jwork的用户,下面是我的配置文件:

二等兵/ etc / apache2 \用户/ jwork上。

<Directory "/Users/jwork/Sites/">
    Require all granted
</Directory>

这个配置完全有效。然而,我发现我的用户配置没有被包括在内:

/私人/ etc /输入/多/ httpd-userdir.conf

## Note how it's commented out by default.
## Just remove the comment to enable your user conf.
#Include /private/etc/apache2/users/*.conf

注意,这是userdir conf文件的默认路径,但正如您将在下面看到的,它是在httpd.conf中可配置的。确保下列行已启用:

/ / etc / apache2 /私人httpd.conf

Include /private/etc/apache2/extra/httpd-userdir.conf

# ...

LoadModule userdir_module libexec/apache2/mod_userdir.so