【问题标题】:Getting "You don't have permission to access / on this server" when trying to access web Application on EC2尝试访问 EC2 上的 Web 应用程序时出现“您无权访问 / 在此服务器上”
【发布时间】:2016-10-20 06:01:30
【问题描述】:

环境:
服务器:AWS EC2-WINDOWS 2012 R2
网络服务器:Apache 2.4.17

简单的网络应用程序,可以从服务器访问,使用带有http://localhost/http://127.0.0.1/的浏览器

但是,当我尝试通过在浏览器中放置我的 ec2 实例公共 DNS ('ec2-.compute.amazonaws.com') 从外部(例如,客户端或任何其他通过 Internet 的机器)访问它时,我得到下列

现在我知道这是网络服务器问题。 EC2 安全规则和 Windows Server 防火墙已被绕过。问题来自我的 Apache 服务器设置。

我在这里花了很多时间尝试所有可能的解决方案:

WAMP error: Forbidden You don't have permission to access /phpmyadmin/ on this server
Forbidden: You don't have permission to access / on this server, WAMP Error
Error message “Forbidden You don't have permission to access / on this server”
You don't have permission to access / on this server

虽然我没有创建虚拟主机。我需要吗?

我当前的httpd.conf有以下设置:

<Directory "C:/wamp64/www/">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
    Require all granted
</Directory>

可能是什么问题?

【问题讨论】:

  • 您是否检查了安全组配置。您是否为输入和输出端口启用了端口 80 和 8080?
  • @JeetendraChoudhary 是的,我认为如果安全组有问题,我应该得到网络服务器的任何响应。安全规则先于访问网络服务器。
  • 我想问题与目录列表有关。您可以尝试在 / 中创建一个子目录并在其中放置一个 index.html 文件并检查您是否可以访问它?
  • @JeetendraChoudhary 我试过了。我在www 下创建了root,并添加了index.html。我尝试使用 url ` ....amazonaws.com/root/index.html` 我得到了相同的结果You don't have permission to access /root/index.html on this server.

标签: apache amazon-web-services amazon-ec2 httpd.conf windows-server-2012-r2


【解决方案1】:

所以这花了我整个周末的时间来弄清楚。但最终,我在answer 中找到了解决方案。对于似乎是一个非常有争议的问题,它就像许多其他高票答案中的隐藏宝藏。

我在这里提供的答案适用于我在问题中提到的特定环境。 httpd.conf文件需要做的改动如下:

  1. &lt;Directory .... &gt;改成这样:

    <Directory "C:/wamp64/www/"> Options Indexes FollowSymLinks MultiViews AllowOverride all Require all granted </Directory>

    我的index.html 文件在www apache 默认目录下

  2. 这就是我被卡住的地方:在同一个文件中,搜索# onlineoffline tag - don't remove,在这一行下面你会找到Require local。将其更改为Require all granted

  3. 别忘了重启 Apache 服务器。

    • 虚拟主机无关。无论您是否使用 Windows 服务器。只要您托管一个网站,就不需要虚拟主机

    • 托管在 EC2 上无关紧要。由于您收到Forbidden 回复,因此您绕过了 EC2 安全组规则和主机服务器防火墙(在本例中为 windows 2012 R2)。响应来自网络服务器。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-06-30
    • 2019-02-22
    • 2017-05-04
    • 2015-10-06
    • 2015-10-07
    • 2012-12-08
    相关资源
    最近更新 更多