VirtualHost 500 error (Apache 2.4.10 / Debian) - apache

Good Morning StackOverFlow.. I have been troubleshooting this for quite a while.
Problem: When I try to access http://newdash.new it returns a 500 error. This happens both when accessing the URL locally and over the LAN.
Running on Debian8 with Apache 2.4.10
Below is my
/etc/apache2/sites-enabled/newdash.conf
Here:
<VirtualHost *:80>
ServerName newdash.new
ServerAdmin webmaster#localhost
DocumentRoot "/var/www/newdash/public"
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory "/var/www/newdash/public">
Order allow,deny
Allow from all
# New directive needed in Apache 2.4.3:
Require all granted
</Directory>
</VirtualHost>
And the permissions:
drwxr-xr-x 11 root root 4096 Nov 13 10:51 newdash
I can ping the named route (newdash.new) both locally and over the LAN and the ip resolves properly.
In my Apache2 error log:
[Fri Nov 13 11:45:51.345101 2015] [:error] [pid 1958] [client 10.1.1.108:56899] PHP Fatal error: Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/var/www/newdash/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied' in /var/www/newdash/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:87\nStack trace:\n#0 /var/www/newdash/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\\Handler\\StreamHandler->write(Array)\n#1 /var/www/newdash/vendor/monolog/monolog/src/Monolog/Logger.php(289):
So it appears there is a permissions error on that directory..
I don't know what other information would be helpful...
Thank you.

I found the error in the error log.
[Fri Nov 13 11:45:51.345101 2015] [:error] [pid 1958] [client 10.1.1.108:56899] PHP Fatal error: Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/var/www/newdash/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied' in /var/www/newdash/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:87\nStack trace:\n#0 /var/www/newdash/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\\Handler\\StreamHandler->write(Array)\n#1 /var/www/newdash/vendor/monolog/monolog/src/Monolog/Logger.php(289):
As suggested, after looking there, I realized the permissions on the /storage/logs/ folder was causing the issues.
Thank you for the suggestion arkascha!

Related

Apache2.4.6 Webdav not working on Centos7

I have installed Apache 2.4.6 on Centos7 official.
httpd.conf was not changed from default.
Configured webdav.conf with the following:
DavLockDB /var/www/html/DavLock
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html/webdav/
ErrorLog /var/log/httpd/error.log
CustomLog /var/log/httpd/access.log combined
Alias /webdav /var/www/html/webdav
<Directory /var/www/html/webdav>
DAV On
</Directory>
</VirtualHost>
webdav directory has 755 rights. DavLock not created.
I keep getting this error and not sure what the cause might be. Have tried many things without success:
[Fri Jan 29 11:41:17.027110 2021] [dav:error] [pid 15068] [client xxx.xxx.xxx.xxx:53946] The locks could not be queried for verification against a possible "If:" header. [500, #0]
[Fri Jan 29 11:41:17.027134 2021] [dav:error] [pid 15068] [client xxx.xxx.xxx.xxx:53946] Could not open the lock database. [500, #400]
[Fri Jan 29 11:41:17.027137 2021] [dav:error] [pid 15068] (13)Permission denied: [client xxx.xxx.xxx.xxx:53946] Could not open property database. [500, #1]
any ideas are welcome
Got it working now.
all files/folders under /var/www/ are chown to apache
moved DavLock to here: /var/lib/dav/
and added this line under httpd.conf:
<IfModule mod_dav_fs.c>
# Location of the WebDAV lock database.
DAVLockDB /var/lib/dav/DavLock
</IfModule>
At this point, I am getting 403 error. Solved by executing the following:
chcon -R -t httpd_sys_content_rw_t /var/www/html/webdav/

Apache server reverse-proxying another apache server, getting "AH01102: error reading status line from remote server"

I have two apache servers setup on two separate physical machines. My current setup is:
Apache 1 (Reverse Proxy) <===> Apache 2
Both apache server versions are Apache/2.4.29 (Ubuntu) running on Ubuntu 18.04.4 LTS and their /etc/apache2/apache.conf files are identical.
Apache 1 sites-enabled config:
<VirtualHost *:80>
ServerName subdomain.domain.tld
ServerAlias www.subdomain.domain.tld
ServerAdmin webmaster#domain.tld
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyRequests off
ProxyPreserveHost On
ProxyPass /maintenance_page !
ProxyPass / http://[apache2-ip-address]:27300/
ProxyPassReverse / http://[apache2-ip-address]:27300/
</VirtualHost>
Apache 2 sites-enabled config:
<VirtualHost *:27300>
ServerName subdomain.domain.tld
ServerAlias www.subdomain.domain.tld
ServerAdmin webmaster#domain.tld
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ErrorDocument 400 /notfound.html
ProxyRequests off
ProxyPreserveHost on
</VirtualHost>
If I directly hit http://[apache2-ip-address]:27300/ from the web browser the apache server landing page comes up fine. If I enter http://subdomain.domain.tld into the browser I get a proxy error:
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request
I logged a trace on both apache servers. Apache server 2 is receiving the proxied request from apache server 1 and is returning a 200 status response perfectly fine to apache server 1. The flow breaks at apache server 1 where I am seeing the following logs:
[Sat Jul 11 20:34:08.671267 2020] [proxy:debug] [pid 32275:tid 140388069250816] proxy_util.c(3075): AH00962: HTTP: connection complete to [apache2-ip-address]:27300 ([apache2-ip-address])
[Sat Jul 11 20:34:08.671333 2020] [core:trace6] [pid 32275:tid 140388069250816] core_filters.c(525): [remote [apache2-ip-address]:27300] core_output_filter: flushing because of FLUSH bucket
[Sat Jul 11 20:34:08.677508 2020] [proxy_http:error] [pid 32275:tid 140388069250816] (104)Connection reset by peer: [client xx.xxx.xxx.xx:39014] AH01102: error reading status line from remote server [apache2-ip-address]:27300
[Sat Jul 11 20:34:08.677575 2020] [proxy_http:debug] [pid 32275:tid 140388069250816] mod_proxy_http.c(1324): [client xx.xxx.xxx.xx:39014] AH01105: NOT Closing connection to client although reading from backend server [apache2-ip-address]:27300 failed.
[Sat Jul 11 20:34:08.677624 2020] [proxy:error] [pid 32275:tid 140388069250816] [client xx.xxx.xxx.xx:39014] AH00898: Error reading from remote server returned by /
[Sat Jul 11 20:34:08.677681 2020] [proxy:debug] [pid 32275:tid 140388069250816] proxy_util.c(2192): AH00943: HTTP: has released connection for ([apache2-ip-address])
[Sat Jul 11 20:34:08.677724 2020] [http:trace3] [pid 32275:tid 140388069250816] http_filters.c(1128): [client xx.xxx.xxx.xx:39014] Response sent with status 502, headers:
Things I've tried, from few other discussions I could find online, are the following changes to apache server 1 sites-enabled config :
SetEnv proxy-initial-not-pooled 1
SetEnv force-proxy-request-1.0 1
SetEnv proxy-nokeepalive 1
ProxyTimeout 600
ProxyPass / http://[apache2-ip-address]:27300/ timeout=600
ProxyPass / http://[apache2-ip-address]:27300/ nocanon
I've pretty much bruteforced the situation with several combinations of the above settings, but nothing seems to work. Any help is appreciated.
An additional check I ran is, if I run a nodejs application or python flask service on the same machine as either apache servers and proxy the service using ProxyPass / http://localhost:[port]/, the setup works properly. So both apache servers are running fine and are able to proxy services on their respective localhosts. Whatever is breaking has to do with the communication between the two apache servers.
UPDATE : Upon further triaging using curl with a networking person, the issue seems to be that the org firewall is only allowing inbound traffic to apache server 2 and blocking outbound traffic which may be causing 502 errors on apache server 1. This didn't seem like the issue up until I realized that my laptop was VPN'ed into the org network all along while testing and apache server 1 is sitting outside the org network. If this turns out to be the issue it's going to be a real bummer.
Adding following parameter in the http.conf file solves my issue of "proxy: error reading status line from remote server":
SetEnv proxy-initial-not-pooled 1
I go the reference from Apache URL https://httpd.apache.org/docs/2.4/mod/mod_proxy_http.html
Note: restart http server and try again.
In my case, an error with the database's connection was triggering this Apache's Reverse Proxyng error.

403 error with LAMP and symfony

With a LAMP server running on Ubuntu 16.04, I get the error in the log file defined as in conf :
[Tue Dec 26 16:56:35.930629 2017] [core:error] [pid 21749] (13)Permission denied: [client 127.0.0.1:43872] AH00035: access to / denied (filesystem path '/home/christophe/public_html') because search permissions are missing on a component of the path
I set my .conf file with the following :
<VirtualHost *:80>
ServerName memory.test
ServerAlias www.memory.test
DocumentRoot /home/christophe/public_html/memory/web
<Directory /home/christophe/public_html/memory/web>
AllowOverride All
Require all granted
Allow from all
</Directory>
ErrorLog /var/log/apache2/memory_error.log
CustomLog /var/log/apache2/memory_access.log combined
</VirtualHost>
The access right are set for user christophe:christophe and www-data is part of the group christophe, the mod is 775 but even with the www-data:www-data I get the error.
The /etc/hosts file contains the line :
127.0.0.1 memory.test
I seem to not have selinux installed as this solution is given in some other questions. I would not consider myself as a newbee and I succeeded to have many test environments working this way but this linux is a fresh installation and for a while no other website is working on it...
Did you check that you have 0644 in the directory you are trying to serve?, besides, you also give permissions to www-data user to access that directory, note that the folder you are trying to serve is located in your home directory.

Apache FastCGI server connection failure

I have a virtual machine base box for Debian wheezy that I've been using with vagrant for the last few months without any issues, however yesterday when I brought up a new machine and updated/upgraded packages I started getting a FastCGI server connection failure error:
[Wed Jun 04 14:39:03 2014] [error] [client 10.0.2.2] (13)Permission denied: FastCGI: failed to connect to server "/vagrant/php5-fcgi": connect() failed
[Wed Jun 04 14:39:03 2014] [error] [client 10.0.2.2] FastCGI: incomplete headers (0 bytes) received from server "/vagrant/php5-fcgi"
I am able to resolve the issue temporarily by manually touching and chmodding /tmp/php5-fpm-vagrant.sock, but my question is why did it start happening all of a sudden?
Personal preferences aside, is there anything functionally wrong with my configuration?:
In my apache sites available I have a file called 000php containing:
FastCgiExternalServer /vagrant/php5-fcgi -socket /tmp/php5-fpm-vagrant.sock -pass-header Authorization
Since apache loads sites alphabetically, this always gets loaded first, then I have another file called vagrant that contains:
<VirtualHost *:80 *:8080>
DocumentRoot /vagrant/public_html/
ServerName vagrant.localhost
<Directory /vagrant/>
AllowOverride all
</Directory>
AddHandler php5-fcgi .php
Action php5-fcgi /php5-fcgi
Alias /php5-fcgi /vagrant/php5-fcgi
ErrorLog ${APACHE_LOG_DIR}/vagrant_error.log
CustomLog ${APACHE_LOG_DIR}/vagrant_access.log combined
</VirtualHost>
and a php fpm pool config called vagrant.conf that looks like this:
[vagrant]
listen = /tmp/php5-fpm-vagrant.sock
listen.allowed_clients = 127.0.0.1
user = vagrant
group = vagrant
pm = ondemand
pm.max_children = 50
any suggestions would be greatly appreciated
Figured out the answer, this was caused by https://bugs.php.net/bug.php?id=67060
The fix was to add the following lines to my vagrant.conf php fpm configuration file and restart php fpm, a reload was not enough
listen.owner = www-data
listen.group = www-data
listen.mode = 0660

Setting up pow.cx to use Apache for PHP apps

I've set up Pow and Apache the way they suggest in this tutorial. My httpd-vhosts.conf contains the following entry.
<VirtualHost *:80>
DocumentRoot /Users/michael/Dropbox/Development/test
ServerName test.dev
<Directory "/Users/michael/Dropbox/Development/test">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I'm still getting a 403 Forbidden when I got to http://test.dev/.
Error log says:
[Wed Nov 21 19:24:21 2012] [crit] [client 127.0.0.1] (13)Permission denied: /Users/michael/Dropbox/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Wed Nov 21 19:24:43 2012] [error] [client 127.0.0.1] (13)Permission denied: access to / denied
Has anyone else had this problem?
This seems to have nothing to do with Pow. Apache doesn't have the necessary permissions to work within /Users/michael/Dropbox/Development/test.
Please check the permissions of this directory, I think they should be 755. Check them with:
cd /Users/michael/Dropbox/Development/
ls -l
And copy paste the line of the test directory.
The issue was the permissions. It finally worked when I chmod'd the full path to the directory I was working in to 755.
~/, ~/Dropbox, ~/Development...etc.
I'll bet there's a nicer way to do this, but it's working. So, there you go.