Apache2.4.6 Webdav not working on Centos7 - apache

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/

Related

Apache2 server failed to start due to error in conf

I am trying to start the apache2 server installed on Ubuntu 22.04 LTS Desktop. However the restart failed and from what I can see in the error log, it is related to my configuration. However I cannot debug further on the exact issue. My apache2 server configuration is as below.
cat /etc/apache2/sites-enabled/000-default.conf
<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 www.example.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
WSGIDaemonProcess flaskapp threads=5 python-home=/home/hd2900/Documents/Python/hd2900TakeawayPrint/env
WSGIScriptAlias / /home/hd2900/Documents/Python/hd2900TakeawayPrint/flaskapp.wsgi
WSGIApplicationGroup %{GLOBAL}
<Directory /home/hd2900/Documents/Python/hd2900TakeawayPrint>
          WSGIProcessGroup flaskapp
          Require all granted
</Directory>
# 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
# 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
When trying to start the server
sudo service apache2 restart
Job for apache2.service failed because the control process exited with error code.
See "systemctl status apache2.service" and "journalctl -xeu apache2.service" for details.
Digging further into systemctl status apache2.service it seems that I have an issue on line 18 in my apache2 configuration file. I have checked that line, and cannot see exactly what the issue is.
systemctl status apache2.service
× apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2022-08-28 00:11:46 CEST; 1min 14s ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 4561 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)
CPU: 66ms
Aug 28 00:11:45 hd2900 systemd[1]: Starting The Apache HTTP Server...
Aug 28 00:11:46 hd2900 apachectl[4564]: AH00526: Syntax error on line 18 of /etc/apache2/sites-enabled/000-default.conf:
Aug 28 00:11:46 hd2900 apachectl[4564]: Invalid command '\xe2\x80\x86', perhaps misspelled or defined by a module not included in the server configuration
Aug 28 00:11:46 hd2900 apachectl[4561]: Action 'start' failed.
Aug 28 00:11:46 hd2900 apachectl[4561]: The Apache error log may have more information.
Aug 28 00:11:46 hd2900 systemd[1]: apache2.service: Control process exited, code=exited, status=1/FAILURE
Aug 28 00:11:46 hd2900 systemd[1]: apache2.service: Failed with result 'exit-code'.
Aug 28 00:11:46 hd2900 systemd[1]: Failed to start The Apache HTTP Server.
I also checked the error.log and get the below print out. I am still not sure what the exact issue is.
cat /var/log/apache2/error.log
[Sat Aug 27 23:42:48.764507 2022] [mpm_event:notice] [pid 2886:tid 281473433382944] AH00489: Apache/2.4.52 (Ubuntu) configured -- resuming normal operations
[Sat Aug 27 23:42:48.765058 2022] [core:notice] [pid 2886:tid 281473433382944] AH00094: Command line: '/usr/sbin/apache2'
[Sat Aug 27 23:46:40.942688 2022] [mpm_event:notice] [pid 2886:tid 281473433382944] AH00492: caught SIGWINCH, shutting down gracefully
[Sat Aug 27 23:46:41.074596 2022] [mpm_event:notice] [pid 4010:tid 281473172430880] AH00489: Apache/2.4.52 (Ubuntu) mod_wsgi/4.9.0 Python/3.10 configured -- resuming normal operations
[Sat Aug 27 23:46:41.075061 2022] [core:notice] [pid 4010:tid 281473172430880] AH00094: Command line: '/usr/sbin/apache2'
[Sat Aug 27 23:52:16.956956 2022] [mpm_event:notice] [pid 4010:tid 281473172430880] AH00491: caught SIGTERM, shutting down

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.

VirtualHost 500 error (Apache 2.4.10 / Debian)

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!

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.

Trouble configuring trac to work with Apache2 [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I've been trying to set up trac to be deployed with apache for a little while now and I'm running into a wall.
I can get it to work via tracd but I'm probably going to have multiple projects and I might want to use TSL for connections to trac.
This is the response I'm receiving from my server
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster#localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Apache/2.2.14 (Ubuntu) Server at ***.***.***.*** Port 80
This is my apache v-host file: (Comments removed)
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DirectoryIndex index.html
DocumentRoot /home/***/public_html/app/public
Alias /trac/chrome/common /home/***/trac/htdocs/common
Alias /trac/chrome/site /home/***/trac/htdocs/common
ScriptAlias /trac /home/***/trac/cgi-bin/trac.fcgi/
DefaultInitEnv TRAC_ENV /home/***/trac
<Location "/trac">
SetEnv TRAC_ENV_PARENT_DIR "home/***/"
</Location>
<Directory "/home/***/trac/htdocs">
Order allow,deny
Allow from all
</Directory>
<Location "/trac/chrome/common">
SetHandler none
</Location>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /home/***/public_html/app/log/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel debug
CustomLog /home/***/public_html/app/log/access.log combined
CustomLog /home/casey/public_html/app/log/access.log combined
</VirtualHost>
And this is my server's error log:
[Fri Apr 29 02:09:06 2011] [warn] [client **.**.**.**] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
[Fri Apr 29 02:09:06 2011] [error] [client **.**.**.**] Premature end of script headers: trac.fcgi
[Fri Apr 29 02:09:06 2011] [debug] mod_deflate.c(615): [client **.**.**.**] Zlib: Compressed 618 to 384 : URL /trac/
[Fri Apr 29 02:09:08 2011] [warn] [client **.**.**.**] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
[Fri Apr 29 02:09:08 2011] [error] [client **.**.**.**] Premature end of script headers: trac.fcgi
[Fri Apr 29 02:09:08 2011] [debug] mod_deflate.c(615): [client **.**.**.**] Zlib: Compressed 618 to 384 : URL /trac/
Does anyone know what might be going on and what I should do to fix it? Thanks!
Is this on Windows? As noted in this question, running Python with FastCGI on Windows is bound to fail.
I recommend switching to mod_wsgi which is the recommended approach anyway.