首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Apache说:“禁止您访问这个资源。”到特定的域

问Apache说:“禁止您访问这个资源。”到特定的域
EN

Server Fault用户
提问于 2019-09-19 15:51:27
回答 1查看 38.1K关注 0票数 2

我在AWS上有一个服务器,它为许多网站服务。还安装了Webmin。

在Apache中,当我尝试创建一个网站时,比如ferrari.example.com,当我使用web浏览器请求它时,我会得到错误Forbidden. You don't have permission to access this resource.。

这不是文件权限问题,因为如果我使用不同的域名(指向同一个目录),它可以正常工作。

这不是Apache配置问题,因为如果我只更改域名(以及其他配置设置),它就能正常工作。

是的,我有一个正确的DNS条目,它指向ferrari.example.com指向我的服务器。

不,在Apache中没有其他站点与域名冲突。我在/etc/apache上做了一个D4,只找到了一个站点。

有其他人知道为什么这不管用吗?

代码语言:javascript
复制
DocumentRoot /var/www/ferrari.example.com
ServerName ferrari.example.com

AllowOverride All
Options None
Require all granted

我想我没有安装SELinux。

日志级调试显示了以下错误:

代码语言:javascript
复制
[Thu Sep 19 19:13:00.740101 2019] [authz_core:debug] [pid 31107] mod_authz_core.c(809): [client 204.112.96.198:13742] AH01626: authorization result of Require all denied: denied, referer: http://ferrari.example.com/
[Thu Sep 19 19:13:00.740130 2019] [authz_core:debug] [pid 31107] mod_authz_core.c(809): [client 204.112.96.198:13742] AH01626: authorization result of : denied, referer: http://ferrari.example.com/
[Thu Sep 19 19:13:00.740139 2019] [authz_core:error] [pid 31107] [client 204.112.96.198:13742] AH01630: client denied by server configuration: /var/www/html/favicon.ico, referer: http://ferrari.example.com/
EN

回答 1

Server Fault用户

发布于 2020-01-17 15:32:44

我也面临着同样的问题。

以下是我是如何解决它的

使用nano编辑器打开apache2.conf文件。

代码语言:javascript
复制
sudo nano /etc/apache2/apache2.conf

用以下内容替换常规目录设置。

代码语言:javascript
复制
    #Options FollowSymLinks
        Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
        Order deny,allow
        Require all granted



    AllowOverride None
    Require all granted



    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted



#
#   Options Indexes FollowSymLinks
#   AllowOverride None
#   Require all granted
#

确保/etc/apache2/sites-available目录中的虚拟主机配置文件是这样的。

代码语言:javascript
复制
        # The ServerName directive sets the request scheme, hostname and port t$
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        ServerName example.com (put your domain name here)

        ServerAdmin webmaster@localhost
        DocumentRoot /home/username/myapp (put your app root directory here)

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf


# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

重新启动Apache2服务

代码语言:javascript
复制
sudo systemctl restart apache2

就这样。

I希望这有助于

票数 0
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/984889

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档