wsgi startup - why two identical processes? - wsgi

I have the following config:
virtualhost:
<VirtualHost *:80>
ServerAdmin rok#localhost
ServerName lh.test.com
WSGIScriptAlias / /home/user/myapp/src/wsgi.py application-group='%{GLOBAL}' process-group='%{GLOBAL}'
WSGIDaemonProcess lh.test.com processes=1 threads=1 display-name=%{GROUP}
<Directory /home/user/myapp/src>
<Files wsgi.py>
Order deny,allow
Require all granted
</Files>
Options All
AllowOverride All
Require all granted
</Directory>
Alias /static /home/user/myapp/src/static
ErrorLog /var/log/apache2/lh.test.com-error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel debug
CustomLog /var/log/apache2/lh.test.com-access.log combined
</VirtualHost>
wsgi.py:
from __future__ import unicode_literals
import os, signal, sys
sys.path.append('/home/user/apps/django-trunk')
sys.path.insert(0, '/home/user/myapp/src')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test.settings")
print 'starting up wsgi application...'
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
When I start apache, it always starts two identical wsgi processes for some reason:
apache log:
Mon Jan 06 21:17:02.895219 2014] [mpm_event:notice] [pid 27628:tid 140594224048000] AH00489: Apache/2.4.6 (Ubuntu) mod_wsgi/3.4 Python/2.7.5+ configured -- resuming normal operations
[Mon Jan 06 21:17:02.895287 2014] [core:notice] [pid 27628:tid 140594224048000] AH00094: Command line: '/usr/sbin/apache2'
[Mon Jan 06 21:17:02.905771 2014] [:error] [pid 27632:tid 140594224048000] starting up wsgi application...
[Mon Jan 06 21:17:02.909542 2014] [:error] [pid 27633:tid 140594224048000] starting up wsgi application...
and ps aux:
root 27628 0.0 0.0 84196 3100 ? Ss 21:17 0:00 /usr/sbin/apache2 -k start
www-data 27632 0.1 0.3 470984 24648 ? Sl 21:17 0:00 /usr/sbin/apache2 -k start
www-data 27633 0.1 0.3 470984 24648 ? Sl 21:17 0:00 /usr/sbin/apache2 -k start
any idea why that is so?

You have the WSGIScriptAlias directive wrong:
WSGIScriptAlias / /home/user/myapp/src/wsgi.py application-group='%{GLOBAL}' process-group='%{GLOBAL}'
It should be:
WSGIScriptAlias / /home/user/myapp/src/wsgi.py application-group='%{GLOBAL}' process-group='lh.test.com'
The result is that your application isn't running in daemon mode but embedded mode, and so is running in the Apache child worker processes. As such how many processes you see is going to be up to the Apache MPM settings.
Change that directive and also set:
WSGIRestrictEmebedded On
This will turn off the ability for stuff to run in the Apache child worker process and cause an error if you stuff up your configuration and don't delegate an application to run in the daemon process group properly.
Also go read:
http://blog.dscpl.com.au/2012/10/why-are-you-using-embedded-mode-of.html

Related

How to fix: Truncated or oversized response headers received from daemon process

I have a flask application that runs on an apache web server, and recently i added a feature using the p4python module. But every time the site calls this package, i get a 500 Internal Server Error. When i check the error log i get the error saying "Truncated or oversized response headers received from daemon process ".
Configuration
Ubuntu 14.04.6
Apache 2.4.7
Python 3.4.3
mod-wsgi 4.6.8
openssl 1.0.1f
Notable python packages are
Flask 1.0.4
psycopg2 2.8.3
p4python 2019.1.1858212
I have tried every solution suggested on the other threads here, and i have tried the debugging suggestions from https://modwsgi.readthedocs.io/en/develop/user-guides/debugging-techniques.html#tracking-request-and-response.
This includes setting WSGIApplicationGroup %{GLOBAL}, increasing the header size and updating mod-wsgi to the newest version using pip.
Unfortunately none of this has worked, and when i call a function using the p4python api the site shows an error.
.conf file
Listen 31415
<VirtualHost *:31415>
ServerName dev-collab
SSLEngine on
SSLCertificateFile /etc/ssl/private/********.cer
SSLCertificateKeyFile /etc/ssl/private/*********.key
WSGIDaemonProcess applicationDash user=www-data group=www-data threads=6 python-home=/var/www/applicationDash/venv
WSGIScriptAlias / /var/www/applicationDash/api.wsgi
ErrorLog "/var/log/apache2/applicationDash_error.log"
CustomLog "/var/log/apache2/applicationDash_access.log" common
LogLevel info
DocumentRoot "/var/www/applicationDash"
<Directory "/var/www/applicationDash">
WSGIProcessGroup applicationDash
WSGIScriptReloading On
WSGIApplicationGroup %{GLOBAL}
</Directory>
Alias /static /var/www/applicationDash/static
<Directory "/var/www/applicationDash/static">
Require all granted
</Directory>
</VirtualHost>
Response header
[wsgi:error] [pid 42349] [remote 10.4.24.191:52037] ('RESPONSE',
[wsgi:error] [pid 42349] [remote 10.4.24.191:52037] '200 OK',
[wsgi:error] [pid 42349] [remote 10.4.24.191:52037] [('Content-Type', 'text/html; charset=utf-8'), ('Content-Length', '5598')])
The actual error
[wsgi:info] [pid 42371] mod_wsgi (pid=42371): Attach interpreter ''.
[wsgi:info] [pid 42371] mod_wsgi (pid=42371): Imported 'mod_wsgi'.
[ssl:info] [pid 41529] [client 10.4.32.52:53304] AH01964: Connection to child 2 established (server dev-collab:443)
[ssl:info] [pid 41529] (70014)End of file found: [client 10.4.32.52:53304] AH01991: SSL input filter read failed.
[ssl:info] [pid 41530] [client 10.4.24.191:58651] AH01964: Connection to child 3 established (server dev-collab:443)
[wsgi:info] [pid 42371] [remote 10.4.24.191:58651] mod_wsgi (pid=42371, process='applicationDash', application=''): Loading Python script file '/var/www/applicationDash/api.wsgi'.
[wsgi:error] [pid 41530] [client 10.4.24.191:58651] Truncated or oversized response headers received from daemon process 'applicationDash': /var/www/applicationDash/api.wsgi, referer: https://dev-collab:31415/branch/3/AccessControl
This is all with LogLevel info.
Does anyone have an idea where my mistake lies?

Migrate web application from xmapp to lamp

I have developed web application using codeigniter on xampp server.
and want to deploy it on LAMP server. I have migrated database and app successfully but facing some problem.
When request web page using browser its not show anything not even error.
I have enabled selinux,
have root account and testing using root account
virtual host file config in /etc/httpd/conf.modules.d/hotelking.conf
<VirtualHost *:80>
ServerName www.hotelking.com
ServerAlias hotelking.com
DocumentRoot /var/www/hotelking/app/
Customlog "logs/www.hotelking.com.log" combined
ErrorLog "log/www.hotelking.com.error_log"
<Directory /var/www/hotelking/app/>
Require all granted
</Directory>
And error log have following error
[Wed Jan 06 03:20:14.515526 2016] [:error] [pid 6912] [client 127.0.0.1:40964] PHP Fatal error: Class 'MY_controller' not found in /var/www/hotelking/app/application/controllers/master.php on line 5
[Wed Jan 06 03:20:21.773841 2016] [:error] [pid 6908] [client 127.0.0.1:40965] PHP Fatal error: Class 'MY_controller' not found in /var/www/hotelking/app/application/controllers/master.php on line 5
I CHECKED IT HAS MY_controller at give location

Apache mod_wl2.4 plugin error parseJVMID

I have some issues with setting an clustered environment for weblogic and Apache. The structure is like this: 1 webserver that proxies requests to a clustered environment of 3 weblogic servers.
Everytime i send the request to the apache server , the request gets unhandled. I figured out a part of the problem , but that is something that is not intended in production. whenever i add DynamicServerList On the requests fail. When i switch it to off it works, but that means whenever a server fails , apache will still send requests to that server and user experience would be 0.
EDIT 1: I am using weblogic 12c and apache2.4 for Centos 7
EDIT 2: There is no firewall nor selinux active
Here is my config file for weblogic plugin:
<VirtualHost *:8080>
ServerAdmin postmaster#webserver2
ServerName webserver2
DocumentRoot /var/www/webserver2/htdocs
ErrorLog /var/log/httpd//webserver-error_log
CustomLog /var/log/httpd/webserver-access_log forwarded
<Directory />
AllowOverride all
Order allow,deny
Allow from all
</Directory>
DirectoryIndex index.html
<Location />
SetHandler weblogic-handler
</Location>
<IfModule mod_weblogic.c>
WeblogicCluster 192.168.166.70:8001,192.168.166.71:8001,192.168.166.69:8001
ConnectTimeoutSecs 15
ConnectRetrySecs 10
WLIOTimeoutSecs 600
DynamicServerList ON
Idempotent ON
FileCaching ON
KeepAliveSecs 60
KeepAliveEnabled ON
DebugConfigInfo ON
</IfModule>
</VirtualHost>
And the errors I get are the following:
[Mon Sep 14 09:54:58.480616 2015] [weblogic:error] [pid 15343:tid
140547949991680] [client 172.18.132.50:57991] <1534314422136982>
parseJVMID: could not resolve hostname '-1062689209'. Returning NULL
from parseJVMID
[Mon Sep 14 09:54:58.480681 2015] [weblogic:error]
[pid 15343:tid 140547949991680] [client 172.18.132.50:57991]
<1534314422136982> initJVMID: parseClusterServerList failure
[Mon Sep
14 09:55:28.481215 2015] [weblogic:error] [pid 15343:tid
140547949991680] [client 172.18.132.50:57991] <1534314422136982>
request [/clusterjsp/HaJsp.jsp] did NOT process
successfully..................

Configure Apache web server to perform SSL authentication

I'm trying to perform SSL authentication in apache web server, using XAMPP in Linux. After I configure httpd.conf like this, Apache server is failing to start. Can some one help me to fix this ? What is wrong with my configuration ?
Alias /bitnami/ "/opt/lampp/apache2/htdocs/"
Alias /bitnami "/opt/lampp/apache2/htdocs"
<Directory "/opt/lampp/apache2/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Listen 443
<VirtualHost 127.0.0.1:443>
DocumentRoot "/opt/lampp/htdocs"
ServerName localhost.localdomain
SSLEngine on
SSLCertificateFile "/home/lahiru/Desktop/ucsc/security/ssl/server.cer"
SSLCertificateKeyFile "/home/lahiru/Desktop/ucsc/security/ssl/server.key"
SSLVerifyClient require
SSLVerifyDepth 10
SSLCACertificateFile "/home/lahiru/Desktop/ucsc/security/ssl/ca.cer"
</VirtualHost>
And the Apache error log says,
(98)Address already in use: AH00072: make_sock: could not bind to address [::]:443
[Sun Jun 21 07:42:47.000754 2015] [ssl:warn] [pid 1863] AH01909: localhost.localdomain:443:0 server certificate does NOT include an ID which matches the server name
[Sun Jun 21 07:42:47.001082 2015] [ssl:warn] [pid 1863] AH01906: www.example.com:443:0 server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Sun Jun 21 07:42:47.001101 2015] [ssl:warn] [pid 1863] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sun Jun 21 07:42:47.001183 2015] [suexec:notice] [pid 1863] AH01232: suEXEC mechanism enabled (wrapper: /opt/lampp/bin/suexec)
Bitnami developer here,
In XAMPP the SSL configuration is located at /opt/lampp/etc/extras/httpd-ssl.conf file, where there is a default VirtualHost already configured in port 443, and you are trying to bind again the same port.
Please, try to modify this file instead. You can check if there is any other process using port 443 running command sudo netstat -vnpa | grep 443
What do you mean with "Apache server is failing to start"? Using the /opt/lampp/ctlscript.sh script to restart Apache server didn't produce any error message on my side but the error_log told me the same that you mentioned.
Regards,
Gonzalo

Wampserver loglevel rewrite not working

I am using WampServer and I would like to debug my rewrite rules from .htaccess, since I still receive 404 errors.
I already enabled rewrite_module, log_debug_module, log_forensic_module and log_config_module, but in my error log I don't receive any information about .htaccess.
In httpd.conf I changed LogLevelto: LogLevel warn mod_rewrite.c:trace8. I also tried the following options: rewrite_module, mod_rewrite.so, rewrite, mod_rewrite.
Then when I restart the server I only get this log, but I don't receive anything about web requests when I try to go to localhost/mysite.
[Sat Oct 12 17:33:07.063441 2013] [mpm_winnt:notice] [pid 8884:tid 412] AH00422: Parent: Received shutdown signal -- Shutting down the server.
[Sat Oct 12 17:33:09.063556 2013] [mpm_winnt:notice] [pid 1632:tid 288] AH00364: Child: All worker threads have exited.
[Sat Oct 12 17:33:09.078557 2013] [mpm_winnt:notice] [pid 8884:tid 412] AH00430: Parent: Child process 1632 exited successfully.
[Sat Oct 12 17:33:48.859832 2013] [mpm_winnt:notice] [pid 8252:tid 412] AH00455: Apache/2.4.4 (Win64) PHP/5.4.12 configured -- resuming normal operations
[Sat Oct 12 17:33:48.859832 2013] [mpm_winnt:notice] [pid 8252:tid 412] AH00456: Server built: Feb 22 2013 22:08:37
[Sat Oct 12 17:33:48.859832 2013] [core:notice] [pid 8252:tid 412] AH00094: Command line: 'c:\\wamp\\bin\\apache\\apache2.4.4\\bin\\httpd.exe -d C:/wamp/bin/apache/Apache2.4.4'
[Sat Oct 12 17:33:48.867833 2013] [mpm_winnt:notice] [pid 8252:tid 412] AH00418: Parent: Created child process 6216
[Sat Oct 12 17:33:49.145848 2013] [mpm_winnt:notice] [pid 6216:tid 288] AH00354: Child: Starting 150 worker threads.
UPDATE
Here is some more information about my folder structure. I have put my DirectoryRoot to D:/www and my .htaccess file is in D:/www/mysite.
Some parts from httpd.conf:
<Directory />
AllowOverride none
Require all granted
</Directory>
DocumentRoot "D:/www"
<Directory "D:/wamp/www">
Options Indexes FollowSymLinks
AllowOverride All
# Require all granted
# onlineoffline tag - don't remove
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from ::1
Allow from localhost
</Directory>
#ErrorLog "logs/error.log"
ErrorLog "c:/wamp/logs/apache_error.log"
#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn rewrite:trace3
Disabling the rewritemodule gives errors on RewriteEngine so I suppose that it does find my .htaccess file.
This is my .htaccess file:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*?)/?$ index.php/$1
Could it be that you are using Apache 2.4.x, if so they have made major changes in the area of logging.
Try
LogLevel alert rewrite:trace3
Also another change is that logged info gets written to the normal error_log file.
Documentation
ADDED After Additional Info added
You have some fairly obvious errors in your httpd.conf file.
Can I suggest you review this document on the WAMPServer forum Wampserver 2.4 What to do after Installing
I just changed my WAMPServer Apache conf as so:
LogLevel warn rewrite:trace8
And got lots of extra lines in my apache_error.log from the rewrite module.
Make sure you are actually running something on the server that will exercise mod_rewrite and the RewriteRule you have in your .htaccess
ERRORS:
#WRONG Allows access to the root of your D: drive and all subfolders, great for hackers
<Directory />
AllowOverride none
Require all granted
</Directory>
#CORRECTED
<Directory />
AllowOverride none
Require all denied
</Directory>
.
#WRONG
DocumentRoot "D:/www"
#CORRECTED
DocumentRoot "d:/wamp/www"
.
#WRONG
<Directory "D:/wamp/www">
Options Indexes FollowSymLinks
AllowOverride All
# Require all granted
# onlineoffline tag - don't remove
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from ::1
Allow from localhost
</Directory>
#CORRECTED
<Directory "D:/wamp/www">
Options Indexes FollowSymLinks
AllowOverride All
# onlineoffline tag - don't remove
Require local
</Directory>
After editting yor 'httpd.conf' log to
LogLevel alert rewrite:trace3
You should restart apache server to apply changes.

Resources