apache2 403 forbidden on parent directory - apache2

When I try to access the parent directory, say localhost/parent, it gives me 403 forbidden. However if I access the sub-directory, say localhost/parent/index.html, it goes through.
I believe it's a config issue but could anyone walk me through a bit here?
I tried to change the apache2.conf as many people suggested but it doesn't work.(shown below)
<Directory "your directory here">
Order allow,deny
Allow from all
Require all granted
</Directory>
The following is what error log says:
[Mon Jul 03 11:32:51.028149 2017] [autoindex:error] [pid 4899] [client 127.0.0.1:42462] AH01276: Cannot serve directory /var/www/html/hub/: No matching DirectoryIndex (index.php,index.cgi,index.pl,index.php,index.xhtml,index.htm) found, and server-generated directory index forbidden by Options directive

It turned out to be a config file issue,
sudo nano /etc/apache2/mods-enabled/dir.conf
Make index.php as the first option and it solved the problem

Related

How to hide/protect Angular application (equivalent htpasswd)

I tried to protect my application (the test environment) to hide it from curious with a htpasswd. Here is my architecture:
[AngularJS] -> [Apache Proxy] -> [Service]
The aim is to block people who has no password.
I tried first to add a htpasswd on my Apache Proxy at the highest level:
<Location "/">
AuthUserFile /etc/apache2/passwords
AuthName "Forbidden"
AuthType Basic
require valid-user
</Location>
Problem: the prompt was fired at each time a request was made (don't know why).
I tried after to reduce the scope:
<Location "/modules/user/">
AuthUserFile /etc/apache2/passwords
AuthName "Forbidden"
AuthType Basic
require valid-user
</Location>
It works because the call to this route is made at each request. Fine.
But now I created a new route : /modules/user/account. I fell in the first problem I have but worse: a prompt is always displayed, and never accepted. Apache in the logs says:
[Mon Nov 23 11:51:55.510434 2015] [authz_core:debug] [pid 3043:tid 139650316363520] mod_authz_core.c(809): [client 164.177.43.41:55888] AH01626: authorization result of Require valid-user : denied (no authenticated user yet), referer: https://test.mysite.com/
htpasswd is maybe the wrong way to protect my application, what should I do?
Thanks

Vagrant machine with Apache 2.4 and PHP 5.2 generates Internal Server Error

Have configured vagrant Ubuntu 14.04 machine with virtual box.
I get the error (in browser)
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at [no address given] to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
And get the error (/var/log/apache2/error.log):
[Wed Apr 01 20:58:34.609309 2015] [fastcgi:error] [pid 24066:tid 3046103872] (104)Connection reset by peer: [client 192.168.33.1:59777] FastCGI: comm with server "/var/www/html/circulocolaborativo.com.br/php5.fcgi" aborted: read failed
[Wed Apr 01 20:58:34.614694 2015] [fastcgi:error] [pid 24066:tid 3046103872] [client 192.168.33.1:59777] FastCGI: incomplete headers (0 bytes) received from server "/var/www/html/circulocolaborativo.com.br/php5.fcgi"
My virtual host is configured with
<VirtualHost *:80>
Servername circulocolaborativo.local
DocumentRoot /var/www/html/circulocolaborativo.com.br
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# ErrorLog "/home/vagrant/logs/error_log"
<Directory /var/www/html/circulocolaborativo.com.br>
Options FollowSymLinks
DirectoryIndex index.php
Allowoverride all
Require all granted
</Directory>
Alias /php5.fcgi /var/www/html/circulocolaborativo.com.br/php5.fcgi
FastCGIExternalServer /var/www/html/circulocolaborativo.com.br/php5.fcgi -flush -host 127.0.0.1:5200 -idle-timeout 900
AddType application/x-httpd-fastphp5 .php
Action application/x-httpd-fastphp5 /php5.fcgi
<Location /var/www/html/circulocolaborativo.com.br/libraries/Sciere/ws/sptl >
AuthType Digest
AuthName "WebService SPTL"
AuthDigestDomain /libraries/Sciere/ws/sptl/
AuthDigestProvider file
AuthUserFile /var/www/html/.digest_pw_sptl
Require valid-user
</Location>
</VirtualHost>
Could someone help me to solve this issue? I can't figure out what is going on. I'm using php-fpm with fastcgi module.

Vagrant 403 Forbidden

I've been running Vagrant successfully for about a week. Last night I ran vagrant reload and now I can no longer access my sites.
VirtualBox version 4.2.16
Vagrant version 1.2.7
My Vagrantfile and bootstrap.sh: https://github.com/kriskd/vagrant-settings
Running on Mac
My files live at /vagrant/Sites. At first my "welcome page" which lives at /vagrant/Sites rendered at
http://localhost:4567/
All my projects are folders under Sites. For example, /vagrant/Sites/test won't render index.html. I get the following
Forbidden
You don't have permission to access / on this server.
Apache/2.4.6 (Ubuntu) Server at localhost Port 4567
The vhost looks like:
<VirtualHost *:80>
DocumentRoot "/vagrant/Sites/test"
ServerName test
<Directory "/vagrant/Sites/test">
AllowOverride All
</Directory>
</VirtualHost>
The vhosts are owned by root. My project files are owned by vagrant and chmod'ed 0777.
After no success, I did a full vagrant destroy followed by vagrant up and then the localhost host welcome page stopped rendering as well with the forbidden error.
My hunch is that this is not a vagrant issue at all but solely an Apache configuration glitch. There are a few things I can think to check.
First, obviously, is to confirm that the user that apache is running under has read and execute permissions for the DocumentRoot folder.
Since you mentioned Apache 2.4, there have been changes in the configs from 2.2. Make sure your Allow from all statements now read Require all granted. (If you were still on 2.2, you'd want to make sure they said Allow from all instead of Deny from all.) In either case, you can set this in each <VirtualHost> individually, or set a default in your <Directory /> block of the main httpd.conf file.
Getting more obscure, you could check for selinux, although I'm pretty sure this isn't present in Ubuntu by default. (It is in CentOS, for example.)
This is solved and in the end came down to some very simple things.
Use "Require All granted" instead of "Allow from All"
Put each websites' content at the same level namely /vagrant/Sites/default, /vagrant/Sites/test, /vagrant/Sites/real-site
Add .conf extension to vhost names such as test.conf and real-site.conf
Add AllowOverride All to vhosts to respect sites' .htaccess file (I realize that was in my original post, it got lost as I tried to solve this)
All very basic things that eluded me for a better part of a week. I hope this can help someone else.
I had the same problem when changing the DocumentRoot.
Since you've changed your DocumentRoot to "/any/path/foo/bar", make sure you have the permissions set on "apache2.conf" for this path.
Search for:
<Directory /any/path/foo/bar>
in apache2.conf
And add a new block like this:
<Directory /any/path/foo/bar>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
And my guess is that everything is gonna be fine!
cd /etc/apache2/sites-available
for file in `ls *`; do sed 's/\(.*<\/Directory.*>\)/Require\ all\ granted\n\1/' $file > $file.new;mv $file.new $file ; done;
because it worked before, I would not waste time on fix file by file

Getting Error "You don't have permission to access / on this server. Apache/2.2.22 (Ubuntu) Server at localhost Port 80

I changed my Document above error when trying to access the localhost.
DocumentRoot /home/kunal/Development/sites
<Directory /home/kunal/Development/sites>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
I ran the a2ensite for new file and restarted the apache server.
I have my sites folder permission set to 777 permission. Still I am getting this error.
Can someone please help me here?
I got the same error, my path was similar to yours like this /home/user/Dropbox/WebDev/ServerRoot. I made the same mistake as you by setting permissions on the last folder or your site folder.
Set your permissions at from the 3rd folder of your file path for me I had to set permissions to the /Dropbox folder then it started to work I recommend you set your permissions on the /Development folder and it will start to work.
Hope this helps you.
I was having the same issue with sites that I have located in my ~/Dropbox directory. I changed the permissions of the directory by running the following command and everything worked like a charm afterwards.
$ chmod 755 ~/Dropbox
Hope this helps.

DirectoryIndex seemingly ignored by apache2

I'm installing Wordpress and getting the problem where it doesn't find index.php. Of course, if I type it explicitly then it's fine. The problem is somehow that DirectoryIndex is not right. I look in mods-enabled/dir.conf and it says:
<IfModule mod_dir.c>
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
</IfModule>
Which appears to be correct. But it doesn't work. I thought maybe some other file somewhere is overriding this but if so, it isn't in mods-enabled as I grepped that folder.
Any ideas?
I think mod_dir isn't loaded,try to command "sudo a2enmod dir" and "service apache2 restart"

Resources