Dancer2 - Cannot deploy with Apache2 using Plack - apache2

I am trying to deploy Dancer2 app using Plack on Apache2. But after changing all the configurations on port 80 - it shows me directory listing instead of the application itself
Here is my running application on local:
root#dancer-cmuscheduler:/home/ADI/dancer_scheduler# plackup
bin/app.psgi HTTP::Server::PSGI: Accepting connections at
http://0:5000/
This runs just fine on port 5000.
However, I would like to deploy on apache2. Here is my configruations:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /data
SetEnv DANCER_ENVIRONMENT "production"
<Directory /var/www/cmuscheduler>
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<Location />
SetHandler perl-script
PerlResponseHandler Plack::Handler::Apache2
PerlSetVar psgi_app /var/www/cmuscheduler/bin/app.psgi
</Location>
ErrorLog ${APACHE_LOG_DIR}/error.log
</VirtualHost>
I have been trying to debug for 4 hours now. The funny thing is there is no helpful logs in the log file associated that would nudge me in the right direction
[Thu Jul 14 02:23:14.424149 2016] [mpm_event:notice] [pid 7468:tid
140401436669824] AH00489: Apache/2.4.7 (Ubuntu) configured -- resuming
normal operations [Thu Jul 14 02:23:14.424306 2016] [core:notice] [pid
7468:tid 140401436669824] AH00094: Command line: '/usr/sbin/apache2'
Please advice

Related

How to redirect a pased on port and path in apache2?

I want to redirect a certain path on my server to another port:
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass /hello http://localhost:8090/
ProxyPassReverse /hello http://localhost:8090/
</VirtualHost>
/etc/apache2/sites-enabled$ ll
lrwxrwxrwx 1 root root 35 Aug 22 2017 000-default.conf -> ../sites-available/000-default.conf
When I access server:80/hello, I'm presented with a 404.
I also have:
sudo a2enmod proxy
sudo a2enmod proxy_http
What might be missing here?
While I don't know why, I could resolve it replacing localhost with 127.0.0.1.

I get error 503 after upgrading to http 2

After upgrading to http 2.0, I always get error 503. Can anyone help me solve the problem?
error.log:
[Mon Jul 19 11:03:26.351473 2021] [mpm_event:notice] [pid 9022:tid 140512076250176] AH00493: SIGUSR1 received. Doing graceful restart
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
[Mon Jul 19 11:03:26.407467 2021] [mpm_event:notice] [pid 9022:tid 140512076250176] AH00489: Apache/2.4.41 (Ubuntu) mod_fcgid/2.3.9 OpenSSL/1.1.1f configured -- resuming normal operations
[Mon Jul 19 11:03:26.407479 2021] [core:notice] [pid 9022:tid 140512076250176] AH00094: Command line: '/usr/sbin/apache2'
In /etc/apache2/mods-enabled I see http2.conf (if I'm right)
Virtual Host via mod_macro:
<Macro VHost $dir $domain>
<VirtualHost *:443>
Protocols h2 http/1.1
SSLEngine on
SSLCertificateFile /etc/ssl/certs/my.crt
SSLCertificateKeyFile /etc/ssl/private/my.key
AccessFileName .htaccess
DocumentRoot $dir/$domain/httpdocs/
ErrorLog $dir/$domain/error.log
ServerName $domain
ServerAlias www.$domain
<Directory />
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<Directory $dir/$domain>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
</VirtualHost>
</Macro>
Update: domain error.log
[Mon Jul 19 12:47:06.338104 2021] [proxy:error] [pid 18649:tid 140511882213120] (13)Permission denied: AH02454: FCGI: attempt to connect to Unix domain socket /run/php/php8.0-fpm.sock (*) failed
[Mon Jul 19 12:47:06.338133 2021] [proxy_fcgi:error] [pid 18649:tid 140511882213120] [client 127.0.0.1:51542] AH01079: failed to make connection to backend: httpd-UDS
[Mon Jul 19 12:47:06.519092 2021] [proxy:error] [pid 18649:tid 140511882213120] (13)Permission denied: AH02454: FCGI: attempt to connect to Unix domain socket /run/php/php8.0-fpm.sock (*) failed
[Mon Jul 19 12:47:06.519108 2021] [proxy_fcgi:error] [pid 18649:tid 140511882213120] [client 127.0.0.1:51542] AH01079: failed to make connection to backend: httpd-UDS, referer: https://s2019/
[Mon Jul 19 12:47:12.305094 2021] [ssl:warn] [pid 9022:tid 140512076250176] AH01906: s2019:443:0 server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Mon Jul 19 12:47:12.305103 2021] [ssl:warn] [pid 9022:tid 140512076250176] AH01909: s2019:443:0 server certificate does NOT include an ID which matches the server name
Thank you for any help!
I hope it will be useful if you encounter the same situation. All I needed to do:
Open /etc/php/<version>/fpm/pool.d and replace values
listen.owner = www-data
listen.group = www-data
with data in /etc/apache2/envvars
export APACHE_RUN_USER=someuser
export APACHE_RUN_GROUP=someuser
And the result will be:
listen.owner = someuser
listen.group = someuser
At the end you need to restart fpm sudo service php<version>-fpm start
By the way, php-fpm version may differ from your php version. For example, entering php -v shows me 7.4. But
<?php phpinfo();
now shows me 8.0. So I had to choose this dir /etc/php/8.0/fpm/pool.d

apache2 - set timeout in xml configuration of sites-enabled

I use this configuration below in order to make my application available via SSL.
My question now would be how it is possible to set a timeout at **.
Is there a way of doing it and how would be the syntax?
# force HTTPS
<VirtualHost *:80>
ServerName app.xy.at
RewriteEngine on
RewriteCond %{SERVER_NAME} =app.xy.at
Redirect permanent "/" https://app.xy.at
RewriteRule (.*) https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
# forward ORDS requests to tomcat
<VirtualHost *:443>
ServerName app.xy.at
# SSL certificates settings
#Include /etc/apache2/conf-enabled/options-ssl-apache.conf
SSLCertificateFile /etc/apache2/ssl/app.xy.at/fullchain.cer
SSLCertificateKeyFile /etc/apache2/ssl/app.xy.at/app.xy.at.key
SSLCertificateChainFile /etc/apache2/ssl/app.xy.at/ca.cer
ProxyRequests on
ProxyPreserveHost On
<Location / >
ProxyPass "ajp://localhost:9090/"
ProxyPassReverse "ajp://localhost:9090/"
</Location>
I will set a timeout because I get the following errors:
[Thu Mar 26 00:10:52.731383 2020] [proxy_ajp:error] [pid 16266:tid
139926293157632] [client
xxx.xxx.3.59:60869] AH00893: dialog to 127.0.0.1:9090 (localhost)
failed, referer:
https domain
[Thu Mar 26 00:10:57.802571 2020] [proxy_ajp:error] [pid 16266:tid
139926720988928]
(70014)End of file found: AH01030: ajp_ilink_receive() can't receive
header
[Thu Mar 26 00:10:57.802597 2020] [proxy_ajp:error] [pid 16266:tid
139926720988928] [client
xxx.xxx.3.59:60875] AH00992: ajp_read_header: ajp_ilink_receive
failed, referer:
https domain
[Thu Mar 26 00:10:57.802628 2020] [proxy_ajp:error] [pid 16266:tid
139926720988928]
(120006)APR does not understand this error code: [client
xxxx.xxxx.3.59:60875] AH00878: read
response failed from 127.0.0.1:9090 (localhost), referer: https domain
and I dont know why.
According to the documentation, You can pass different parameters along with the URL, in the format of key value pairs
ProxyPass "protocol://domain.com" key1=value1 key2=value2 ...
for your case,
ProxyPass "ajp://localhost:9090/" connectiontimeout=10 timeout=50
connectiontimeout : Connect timeout in seconds. The number of seconds
Apache httpd waits for the creation of a connection to the backend to
complete. By adding a postfix of ms, the timeout can be also set in
milliseconds.
timeout : Connection timeout in seconds. The number of seconds Apache
httpd waits for data sent by / to the backend.

Timeout when reading response headers from daemon process

I am using mod_wsgi with apache2.
[Thu Aug 29 10:50:48.050923 2019] [mpm_prefork:notice] [pid 24309] AH00163: Apache/2.4.18 (Ubuntu) mod_fastcgi/mod_fastcgi-SNAP-0910052141 mod_wsgi/4.3.0 Python/2.7.12 configured -- resuming normal operations
From the above line, you can see that mod_wsgi version is 4.3.0 and apache 2.4.18.
I am running a web application made of Trac framework. And a Django app. Both of them interconnected with some linking. And a Zend app is also part of the overall system.
The major problem is that the app goes unusable by producing "Gateway time out" errors.
When examined, I found 'apache2' is taking too much of CPU. Sometimes 'postgresql' takes too much of CPU. I am not sure why this is happening. In a hope, I tried restarting the services apache and postgresql but it doesn't help much. The same problem continues.
30820 postgres 20 0 314748 46120 42936 R 98.3 1.1 0:26.04 postgres
Above line is part of 'top' command in which postgres uses 98.3% of CPU.
Below is my virtual host script.
<VirtualHost *:80>
ServerName subdomain.domain.com
WSGIDaemonProcess prismdjango user=www-data group=www-data home=/opt/Production/CustomPlugins/CommonPlugin/PRISMDJANGO
WSGIDaemonProcess prismnew user=www-data group=www-data home=/opt/PRISM30/
WSGIScriptAlias /audittool /opt/Production/CustomPlugins/CommonPlugin/PRISMDJANGO/PRISMDJANGO/wsgi.py
WSGIScriptAlias /api /opt/Production/CustomPlugins/CommonPlugin/PRISMDJANGO/PRISMDJANGO/wsgi.py
WSGIScriptAlias /project /opt/Production/CustomPlugins/CommonPlugin/PRISMDJANGO/PRISMDJANGO/wsgi.py
WSGIScriptAlias /accounts /opt/PRISM30/PRISM30/wsgi.py
WSGIProcessGroup prismdjango
WSGIProcessGroup prismnew
Alias /Audittool/static /opt/Production/CustomPlugins/CommonPlugin/PRISMDJANGO/Audittool/static
Alias /user_deactivate /var/www/html/user_deactivate
Alias /contractual_requirements/static /opt/PRISM30/contractual_requirements/static/
<Directory /opt/PRISM30>
WSGIProcessGroup prismnew
WSGIApplicationGroup %{GLOBAL}
Require all granted
Options ExecCGI
AddHandler wsgi-script .wsgi
#Options Indexes FollowSymLinks Includes ExecCGI
#AllowOverride All
#Require all granted
<Files PRISM30/wsgi.py>
Require all granted
</Files>
</Directory>
<Directory /opt/Production/CustomPlugins/CommonPlugin/PRISMDJANGO>
WSGIProcessGroup prismdjango
WSGIApplicationGroup %{GLOBAL}
Require all granted
Options ExecCGI
AddHandler wsgi-script .wsgi
#Options Indexes FollowSymLinks Includes ExecCGI
#AllowOverride All
#Require all granted
<Files PRISMDJANGO/wsgi.py>
Require all granted
</Files>
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
DocumentRoot /opt/TracProjects
WSGIDaemonProcess prism user=www-data group=www-data home=/opt/TracProjects
WSGIScriptAlias / /usr/share/trac/trac.wsgi
WSGIProcessGroup prism
<Directory "/opt/TracProjects">
WSGIApplicationGroup %{GLOBAL}
Options Indexes FollowSymLinks
#AddHandler cgi-script .cgi
#Options Indexes ExecCGI
#DirectoryIndex index.cgi
Order allow,deny
Allow from all
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
</Directory>
<Location /opt/TracProjects>
WSGIProcessGroup prism
</Location>
# TRAC ENV PARENT DIRECTORIES SETUP
DirectoryIndex index.php index.cgi
Alias /authtimesheet "/var/www/ZendApp/public"
#DocumentRoot /var/www/ZendApp/public
#SetEnv APPLICATION_ENV "development"
<Directory /var/www/ZendApp/public>
Options Indexes FollowSymLinks
DirectoryIndex index.php
AllowOverride All
#Order allow,deny
#Allow from all
Require all granted
</Directory>
</VirtualHost>
From apache log file,
[Wed Aug 28 18:31:25.478081 2019] [wsgi:error] [pid 23046] [client 172.24.188.116:36348] Timeout when reading response headers from daemon process 'prism': /usr/share/trac/trac.wsgi, referer: http://subdomain.domain.com
[Wed Aug 28 18:34:30.461158 2019] [wsgi:error] [pid 24138] [client 172.24.188.116:36576] Truncated or oversized response headers received from daemon process 'prism': /usr/share/trac/trac.wsgi, referer: http://subdomain.domain.com
I just want to get rid of this Time outs!Hope this Truncated or oversized response would be of another clue.
Below line is from postgresql log.
could not receive data from client: Connection reset by peer.

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.

Resources