apache + symlinks = 403 - apache

So I've been reading up a lot on the subject but can't figure out what I'm doing wrong, I also tried a couple solutions found here but still...
I have multilple vhosts set up with Apache, everything working fine serving different files from both /home/usr1/html and /home/usr2/html.
Now I symlinked /home/usr1/html/thisfolder to /home/usr2/html/thatfolder, double checked the FollowSymlinks option is enabled both in apache2.conf and in vhost.conf, but I'm getting a 403 Error.
Why should this be about permits? I mean, www-data can read without any problem from both folders, how is it that when symlinked it just doesn't?
Thanks
EDIT:
Error returned by Apache: (notice the missing script filename, only extension is provided)
[Wed Apr 20 12:13:11.297208 2016] [authz_core:error] [pid 19883] [client 192.168.0.1:12345] AH01630: client denied by server configuration: /home/usr2/html/thatfolder/.php
Virtual Host conf file:
<VirtualHost *:80>
ServerName server.domain.lan
ServerAdmin adm#lan
DocumentRoot /home/usr2/html
<Directory /home/usr2/html>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<Directory /home/usr1/html/thisfolder> // original folder
Require all granted
</Directory>
</VirtualHost>

Related

Cannot serve directory /var/www/html/: No matching DirectoryIndex

I'm sure this question has been asked and answered, but I'm not finding a solution. I have a virtual host I have just added SSL to, and it isns't working as expected. The non-SSL version is working properly. Below is what I've got in httpd.conf:
<VirtualHost mysite.com:443>
ServerAdmin email#myemail.com
ServerName mysite.com
ServerAlias www.mysite.com
DocumentRoot /var/www/html/www.mysite.com
<Directory /var/www/html/www.mysite.com>
DirectoryIndex index.html index.htm index.php
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/my.crt
SSLCertificateKeyFile /etc/pki/tls/private/my.key
</VirtualHost>
The error I'm getting is:
[Thu Jan 11 12:29:58.984354 2018] [autoindex:error] [pid 19998] [client
IP:38470] AH01276: Cannot serve directory /var/www/html/: No matching
DirectoryIndex (index.html,index.php) found, and server-generated directory
index forbidden by Options directive
Obviously, I've got the directory set as /var/www/html/www.mysite.com, but it's trying to serve content directly from /var/www/html.
I'm sure this is something simple, but my brain is already oatmeal from working on this site all day, so I'm probably just failing to see what's right in front of my face.
Thanks!
Fixed it. Simple enough, as I assumed. Change:
<VirtualHost mysite.com:443>
To:
<VirtualHost *:443>

Multiviews on VPS gives me Negotiation error

I'm just started using a VPS and i'm pretty new to Apache and everything.
So i have a few sites up and running, but for some reason i can't get Multiviews to work. I've searched on the internet and found an article that describes my problem, but their solution doesn't work. Also this thread on stackoverflow don't seem to work for me.
I started with the following (site.conf) configuration file in /etc/apache2/sites-availlable
<VirtualHost *:80>
ServerName site.com
DocumentRoot /var/www/vhosts/site.com/webroot/
<Directory /var/www/vhosts/site.com/webroot/>
Options Indexes FollowSymLinks Multiviews
AllowOverride all
</Directory>
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/site_acces.log combined
ErrorLog ${APACHE_LOG_DIR}/site_error.log
</VirtualHost>
Now when i go to www.site.com/index.php it works fine, but www.site.com/index gives me a 404 and the following log message:
[Tue Feb 24 10:18:45 2015] [error] [client 213.125.184.74] Negotiation: discovered file(s) matching request: /var/www/vhosts/site.com/webroot/index (None could be negotiated).
So i changed site.conf to the following:
<VirtualHost *:80>
ServerName site.com
DocumentRoot /var/www/vhosts/site.com/webroot/
<Directory /var/www/vhosts/site.com/webroot/>
Options Indexes +FollowSymLinks -Multiviews
AllowOverride all
</Directory>
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/site_acces.log combined
ErrorLog ${APACHE_LOG_DIR}/site_error.log
</VirtualHost>
Unfortunately, still the same error in my log file, so i disabled the negotiation module (as mentioned), but that just gives me this message:
[Tue Feb 24 10:21:02 2015] [error] [client 213.125.184.74] File does not exist: /var/www/vhosts/site.com/webroot/index
After all my modifications to site.conf i did an service apache2 restart and/or service apache2 reload
At this point i have no clue on how to solve this problem so i hope anyone point me in the right direction.
I think "Options Indexes FollowSymLinks Multiviews" is the correct configuration. And yes, you need do "apache reload" after you modify the configuration.
Also make sure you accept "php" in content Negotiation. (by default it might not accept)

Apache Virtual Host configuration issue

my httpd-vhosts.conf
<VirtualHost *:80>
ServerName localhost
DocumentRoot /Library/WebServer/Documents/
</VirtualHost>
<VirtualHost *:80>
ServerName education.com
ServerAlias www.education.com
DocumentRoot "/Library/WebServer/Documents/Education"
ErrorLog "/private/var/log/apache2/education.com-error_log"
CustomLog "/private/var/log/apache2/education.com-access_log" common
<Directory "/Library/WebServer/Documents/Education">
Options Indexes FollowSymLinks
AllowOverride All
Order allow, deny
Allow from all
</Directory>
</VirtualHost>
and my hosts file is
127.0.0.1 education.com
127.0.0.1 www.education.com
I'm on a mac, not sure what am I doing wrong here. (if i remove
<VirtualHost
section localhost works fine, otherwise none of them works)
log says
[Sat May 03 15:17:09 2014] [error] [client 127.0.0.1] client denied by server configuration: /usr/\xe2\x80\x9c, referer: http://education.com/
[Sat May 03 15:17:46 2014] [error] [client 127.0.0.1] client denied by server configuration: /usr/\xe2\x80\x9c
define your directory like this:
<Directory "/Library/WebServer/Documents/Education">
Options Indexes FollowSymLinks
AllowOverride All
Order allow, deny
Allow from all
Require all granted
</Directory>

Vagrant + Puppet + Apache : 403 error

I have a problem with Apache, using Vagrant and Puppet.
With Vagrant, I mount my app folder like this :
config.vm.synced_folder "./../", "/home/vagrant/myapp/", id: "myapp-sources", :owner => "root", :group => "root"
With I provision my vhost with puppet. It looks like this :
<VirtualHost *:80>
ServerAdmin webmaster#myapp
DocumentRoot /home/vagrant/myapp/web
DirectoryIndex index.php index.html index.htm
ServerName myapp.vagrant
ServerAlias myapp.vagrant *.myapp.vagrant
ErrorLog /var/log/apache2/myapp-error_log
CustomLog /var/log/apache2/myapp-access_log common
<Directory /home/vagrant/myapp/web>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
When I access myapp.vagrant from my browser (I modified my /etc/hosts) I get a 403 error. In /var/log/apache2/myapp-error_log, I read this :
[Tue Dec 31 10:33:00.841882 2013] [authz_core:error] [pid 998] [client 192.168.33.1:55878] AH01630: client denied by server configuration: /home/vagrant/myapp/web/
I have no .htaccess file in my web folder.
I don't know where to look to solve this.
By the way, accessing my VM via it's IP in my browser shows the Apache "It works !" page in /var/www (user root, group root) and I have a virtual host to redirect myapp.vagrant:8000 to /usr/share/phpmyadmin (user root, group root) and it works fine.
Are you by any chance using Apache 2.4? A simple search revealed it is likely a new permission model that's causing grief: http://dabase.com/blog/AH01630:_client_denied_by_server_configuration/

Apache 2.4.6 on Ubuntu Server: Client denied by server configuration (PHP FPM) [While loading PHP file]

Today I was updated Ubuntu server 13.04 (Raring Ringtail) → 13.10 (Saucy Salamander).
And my Apache 2 installation is broken.
Here my configuration:
File error.log
[Fri Oct 18 10:48:07.237170 2013] [:notice] [pid 8292:tid 139804677900160] FastCGI: process manager initialized (pid 8292)
[Fri Oct 18 10:48:07.241185 2013] [mpm_event:notice] [pid 8289:tid 139804677900160] AH00489: Apache/2.4.6 (Ubuntu) mod_fastcgi/mod_fastcgi-SNAP-0910052141 configured -- resuming normal operations
[Fri Oct 18 10:48:07.241652 2013] [core:notice] [pid 8289:tid 139804677900160] AH00094: Command line: '/usr/sbin/apache2'
[Fri Oct 18 10:48:28.313923 2013] [authz_core:error] [pid 8294:tid 139804573181696] [client 81.219.59.75:3536] AH01630: client denied by server configuration: /usr/lib/cgi-bin/php5-fcgi
File default.conf
#EU
<VirtualHost *:80>
#ServerName
DocumentRoot /var/www/dev_stable
DirectoryIndex index.php index.html index.htm
<Directory /var/www/dev_stable>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Require all granted
</Directory>
</VirtualHost>
File mods-enabled/fastcgi.conf
#<IfModule mod_fastcgi.c>
# AddHandler fastcgi-script .fcgi
# FastCgiWrapper /usr/lib/apache2/suexec
# FastCgiIpcDir /var/lib/apache2/fastcgi
#</IfModule>
<IfModule mod_fastcgi.c>
AddHandler php5-fcgi .php
Action php5-fcgi /php5-fcgi
Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -socket /var/run/php5-fpm.sock -pass-header Authorization
</Ifmodule>
When I trying to load the file via the browser I got:
site_name/TEST/
Forbidden
You don't have permission to access /php5-fcgi/TEST/index.php on this server.
What should I to fix it?
I have exactly the same issue. I ran a couple of virtual hosts on my local machine for developing.
First, I changed /etc/apache2/conf-available/php5-fpm.conf. I replaced every
Order Deny,Allow
Deny from all
to
Require all granted
The configuration has to be enabled by a2enconf php5-fpm. I did the same with my virtual hosts configurations and made the replacements.
I think this is not advised for security reasons, but as long as I use my server for local purposes only I can live with it.
I ran into this exact issue upon a new install of Apache 2.4. After a few hours of googling and testing I finally found out that I also had to allow access to the directory that contains the (non-existent) target of the Alias directive. That is, this worked for me:
# File: /etc/apache2/conf-available/php5-fpm.conf
<IfModule mod_fastcgi.c>
AddHandler php5-fcgi .php
Action php5-fcgi /php5-fcgi
Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -socket /var/run/php5-fpm.sock -pass-header Authorization
# NOTE: using '/usr/lib/cgi-bin/php5-cgi' here does not work,
# it doesn't exist in the filesystem!
<Directory /usr/lib/cgi-bin>
Require all granted
</Directory>
</Ifmodule>
I ran into a similar problem today (but with mod_wsgi). It might be an Apache 2.2-to-2.4 problem. A comprehensive list of changes can be found here.
For me, it helped to add an additional <Directory>-entry for every path the error-log was complaining about and filling the section with Require all granted.
So in your case you could try
<Directory /usr/lib/cgi-bin/php5-fcgi>
Require all granted
Options FollowSymLinks
</Directory>
and I had to move my configuration file from folder conf.d to folder sites-enabled.
All in all, that did the trick for me, but I don't guarantee it works in your case as well.
I recently ran into the same problem. I had to change my virtual hosts from:
<VirtualHost *:80>
ServerName local.example.com
DocumentRoot /home/example/public
<Directory />
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
To:
<VirtualHost *:80>
ServerName local.example.com
DocumentRoot /home/example/public
<Directory />
Options All
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
In apache2.conf, replace or delete <Directory /> AllowOverride None Require all denied </Directory>, like suggested Jan Czarny.
For example:
<Directory />
Options FollowSymLinks
AllowOverride None
#Require all denied
Require all granted
</Directory>
This worked in Ubuntu 14.04 (Trusty Tahr).
Your virtualhost filename should be mysite.com.conf and should contain this info
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# 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 mysite.com
ServerAlias www.mysite.com
ServerAdmin info#mysite.com
DocumentRoot /var/www/mysite
# 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
<Directory "/var/www/mysite">
Options All
AllowOverride All
Require all granted
</Directory>
# 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
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
I don't think that replacing "Require all denied" with "Require all granted" in this directive:
<Directory>
Options FollowSymLinks
AllowOverride None
#Require all denied
Require all granted
</Directory>
as suggested by Jan Czarny and seonded by user3801675 is the most secure way of solving this problem.
According to the Apache configuration files, that line denies access to the entirety of your server's filesystem. Replacing it might indeed allow access to your virtual host folders but at the price of allowing access to your entire computer as well!
Gev Balyan's approach seems to be the most secure approach here. It was the answer to the "access denied problems" plaguing me after setting up my new Apache server this morning.
And I simply got this error because I used a totally different DocumentRoot directory.
My main DocumentRoot was the default /var/www/html
and on the VirtualHost I used /sites/example.com
I have created a link on /var/www/html/example.com (to /sites/example.com).
DocumentRoot was set to /var/www/html/example.com
It worked like a charm.
I had the same issue after upgrading my system.
In my case, the problem was caused by the order of loading configuration files.
In the /etc/httpd/httpd.confinitally it was defined as follows:
IncludeOptional conf.d/*.conf
IncludeOptional sites-enabled/*.conf
After some hours of attempts, I tried the following order:
IncludeOptional sites-enabled/*.conf
IncludeOptional conf.d/*.conf
And it works fine now.
I had the following configuration in my httpd.conf that denied executing the wpadmin/setup-config.php file from wordpress. Removing the |-config part solved the problem.
I think this httpd.conf is from plesk but it could be some default suggested config from wordpress, i don't know. Anyway, I could safely add it back after the setup finished.
<LocationMatch "(?i:(?:wp-config\\.bak|\\.wp-config\\.php\\.swp|(?:readme|license|changelog|-config|-sample)\\.(?:php|md|txt|htm|html)))">
Require all denied
</LocationMatch>
For those of you on AWS (Amazon Web Services), remember to add a rule for your SSL port (in my case 443) to your security groups. I was getting this error because I forgot to open the port.
3 hours of tearing my hair out later...