0

Environment:
Server: AWS EC2-WINDOWS 2012 R2
Web Server: Apache 2.4.17

The simple web application, is accessible from the server, using the browser with http://localhost/ and http://127.0.0.1/

However, when I try to access it from outside (e.g., client, or any other machine through internet) by placing my ec2 instance public DNS ('ec2-.compute.amazonaws.com') in the browser, I get the following enter image description here

Now I know this is web server issue. EC2 security rules, and Windows Server firewall have been bypassed. The issue is coming from my Apache server settings.

I spent significant time trying all possible solutions here:

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

I did not create virtual host though. Do I need to?

My current httpd.conf has the following settings:

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

What could be the problem?

Community
  • 1
  • 1
Hawk
  • 5,060
  • 12
  • 49
  • 74
  • Have you checked the security group configuration. Have you enabled port 80 and 8080 for in and out port? – Jeet Jun 18 '16 at 14:07
  • 1
    @JeetendraChoudhary Yes, and I think if there is issue with security groups, I should get any response from web server. The security rules come before accessing the web server. – Hawk Jun 18 '16 at 14:09
  • I guess then issue is related to directory listing. can you try creating a subdirectory within / and put an index.html file there and check if you can access it? – Jeet Jun 18 '16 at 14:12
  • @JeetendraChoudhary I tried. I created `root` under `www`, and added `index.html`. I tried with the url ` ....amazonaws.com/root/index.html` I got the same result `You don't have permission to access /root/index.html on this server.` – Hawk Jun 18 '16 at 14:26

1 Answers1

0

So this has taken my whole weekend to figure out. But eventually, I found the solution in this answer. It was like a hidden treasure among many other answers with high votes, for what seems to be a very contentious issue.

I provide an answer here that applies to the particular environment I mentioned in the questions. The changes required on the httpd.conf file are as follows:

  1. Change <Directory .... > to be like this:

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

    where my index.html file is under www apache default directory

  2. And this is where I was stuck: In the same file, search for # onlineoffline tag - don't remove, below this line you'll find Require local. Change it to Require all granted.

  3. Do not forget to restart Apache server.

    • Virtual host is irrelevant. Whether you are using Windows server or not. As long you have one website hosted, no need for the virtual host

    • Being hosted on EC2 is irrelevant. Since you get the Forbidden reply, you are bypassed EC2 security group rules, and host server firewall (in this case windows 2012 R2). The response is coming from the web server.

Community
  • 1
  • 1
Hawk
  • 5,060
  • 12
  • 49
  • 74