Nothing seems to happen, no output appears in the apache logs, but I might be applying the middleware in a wrong way. Here is my wsgi.py file:
""" WSGI config for BalkanCMS project. It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/ """ import os import sys sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../../"))) sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../"))) os.environ.setdefault("DJANGO_SETTINGS_MODULE", "BalkanCMS.settings") from django.core.wsgi import get_wsgi_application application = get_wsgi_application() # Logging WSGI middleware. import pprint class LoggingMiddleware: def __init__(self, application): self.__application = application def __call__(self, environ, start_response): errors = environ['wsgi.errors'] pprint.pprint(('REQUEST', environ), stream=errors) def _start_response(status, headers, *args): pprint.pprint(('RESPONSE', status, headers), stream=errors) return start_response(status, headers, *args) return self.__application(environ, _start_response) application = LoggingMiddleware(application) On Thursday, November 26, 2015 at 1:53:37 PM UTC+2, Graham Dumpleton wrote: > > Lets now confirm that the 500 is coming from Django or whether is from > Apache. > > Use a WSGI middleware wrapper described in: > > > https://code.google.com/p/modwsgi/wiki/DebuggingTechniques#Tracking_Request_and_Response > > to capture the request and response. > > Is the application actually returning a 500, or perhaps instead returning > a different error code. > > There are cases where for a non 200 error code other than 500 that Apache > can try and map it to an ErrorDocument but if that is mapping back into the > application and also has an error, Apache will fall back to generating a > 500 response. > > So lets just make sure we know what is going in and out of the application > and that it looks like what is expected. > > Also check what gets logged in the Apache access log at the same time. > > Am sleeping now, so will see what you find in the morning. > > Graham > > On 26 Nov 2015, at 10:40 PM, Arjan van Eersel <[email protected] > <javascript:>> wrote: > > Debug mode is enabled, still get only the error 500. > > Is there a way to get or log those exception details? These details should > put me on the right track to solve the issue. > > Arjan > > On Thursday, November 26, 2015 at 1:30:09 PM UTC+2, Graham Dumpleton wrote: >> >> As first step, enable DEBUG mode in Django settings module to see if that >> fixes the issue or at least causes a description of the error in the >> browser. >> >> It is quite common to get a 500 error response delivered back from Django >> with no record of the exception being logged. This is because Django >> doesn’t log exception details by default. >> >> Graham >> >> On 26 Nov 2015, at 9:34 PM, Arjan van Eersel <[email protected]> >> wrote: >> >> I'm trying to deploy a Django site through apache 2 as a wsgi daemon. Yet >> I keep getting an error 500 message, but no message in the apache logs at >> all. How can I get more information on what causes this error? >> >> I also made a quick helloworld wsgi app to test, here everything goes >> fine, so the problem seems to be related to the django app. The server uses >> virtualmin for management of the virtual host. And I've searched (and >> found) many related issues on the internet, still whatever I try I can't >> fix this problem. The irony is that I can run other instances of the same >> app without any problems on the same server. There are 3 other sites >> running on exactly the same app on the same server. >> >> *Virtual host settings:* >> SuexecUserGroup "#1237" "#1136" >> ServerName aldeimbg.org >> ServerAlias www.aldeimbg.org >> ServerAlias webmail.aldeimbg.org >> ServerAlias admin.aldeimbg.org >> ServerAlias autoconfig.aldeimbg.org >> >> #LogLevel debug >> >> Alias /static /home/aldeimbg/python/BalkanCMS/static >> <Directory /home/aldeimbg/python/BalkanCMS/static> >> Order deny,allow >> Allow from all >> </Directory> >> >> Alias /media /home/aldeimbg/python/UserContent/media >> <Directory /home/aldeimbg/python/UserContent/media> >> Order deny,allow >> Allow from all >> </Directory> >> >> WSGIDaemonProcess aldeimbg.org >> python-path=/home/aldeimbg/env/lib/python2.7/site-packages >> WSGIProcessGroup aldeimbg.org >> WSGIApplicationGroup %{GLOBAL} >> WSGIScriptAlias / /home/aldeimbg/python/BalkanCMS/wsgi.py >> WSGIPassAuthorization On >> >> <Directory /home/aldeimbg/python/BalkanCMS> >> #Require all granted >> Order allow,deny >> Allow from all >> </Directory> >> >> ErrorLog /var/log/virtualmin/aldeimbg.org_error_log >> CustomLog /var/log/virtualmin/aldeimbg.org_access_log combined >> ScriptAlias /cgi-bin/ /home/aldeimbg/cgi-bin/ >> ScriptAlias /awstats/ /home/aldeimbg/cgi-bin/ >> ScriptAlias /AutoDiscover/AutoDiscover.xml >> /home/aldeimbg/cgi-bin/autoconfig.cgi >> ScriptAlias /Autodiscover/Autodiscover.xml >> /home/aldeimbg/cgi-bin/autoconfig.cgi >> ScriptAlias /autodiscover/autodiscover.xml >> /home/aldeimbg/cgi-bin/autoconfig.cgi >> >> <Directory /home/aldeimbg/cgi-bin> >> allow from all >> AllowOverride All >> Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch >> </Directory> >> RewriteEngine on >> RewriteCond %{HTTP_HOST} =webmail.aldeimbg.org >> RewriteRule ^(.*) https://aldeimbg.org:20000/ [R] >> RewriteCond %{HTTP_HOST} =admin.aldeimbg.org >> RewriteRule ^(.*) https://aldeimbg.org:10000/ [R] >> RemoveHandler .php >> RemoveHandler .php5 >> php_admin_value engine Off >> IPCCommTimeout 31 >> FcgidMaxRequestLen 1073741824 >> <Files awstats.pl> >> AuthName "aldeimbg.org statistics" >> AuthType Basic >> AuthUserFile /home/aldeimbg/.awstats-htpasswd >> require valid-user >> </Files> >> Alias /dav /home/aldeimbg/public_html >> Alias /pipermail /var/lib/mailman/archives/public >> <Location /dav> >> DAV on >> AuthType Basic >> AuthName "aldeimbg.org" >> AuthUserFile /home/aldeimbg/etc/dav.digest.passwd >> Require valid-user >> ForceType text/plain >> Satisfy All >> RemoveHandler .php >> RemoveHandler .php5 >> RewriteEngine off >> </Location> >> RedirectMatch /cgi-bin/mailman/([^/\.]*)(.cgi)?(.*) >> https://aldeimbg.org:10000/virtualmin-mailman/unauthenticated/$1.cgi$3 >> RedirectMatch /mailman/([^/\.]*)(.cgi)?(.*) >> https://aldeimbg.org:10000/virtualmin-mailman/unauthenticated/$1.cgi$3 >> Redirect /mail/config-v1.1.xml /cgi-bin/autoconfig.cgi >> >> *wsgi.py:* >> >> """ >> WSGI config for BalkanCMS project. >> >> It exposes the WSGI callable as a module-level variable named >> ``application``. >> >> For more information on this file, see >> https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/ >> """ >> >> import os >> import sys >> >> sys.path.insert(0, >> os.path.abspath(os.path.join(os.path.dirname(__file__), "../../"))) >> sys.path.insert(0, >> os.path.abspath(os.path.join(os.path.dirname(__file__), "../"))) >> os.environ.setdefault("DJANGO_SETTINGS_MODULE", "BalkanCMS.settings") >> >> from django.core.wsgi import get_wsgi_application >> application = get_wsgi_application() >> >> *settings.py* >> >> DEBUG = True (tried with False too, but get the same error) >> >> TEMPLATE_DEBUG = True >> >> ALLOWED_HOSTS = ['*',] >> >> I can access the app through manage.py runserver without problems >> >> *Apache version info:* >> Server version: Apache/2.2.22 (Ubuntu) >> Server built: Jul 24 2015 17:25:42 >> Server's Module Magic Number: 20051115:30 >> Server loaded: APR 1.4.6, APR-Util 1.3.12 >> Compiled using: APR 1.4.6, APR-Util 1.3.12 >> Architecture: 64-bit >> Server MPM: Prefork >> threaded: no >> forked: yes (variable process count) >> Server compiled with.... >> -D APACHE_MPM_DIR="server/mpm/prefork" >> -D APR_HAS_SENDFILE >> -D APR_HAS_MMAP >> -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled) >> -D APR_USE_SYSVSEM_SERIALIZE >> -D APR_USE_PTHREAD_SERIALIZE >> -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT >> -D APR_HAS_OTHER_CHILD >> -D AP_HAVE_RELIABLE_PIPED_LOGS >> -D DYNAMIC_MODULE_LIMIT=128 >> -D HTTPD_ROOT="/etc/apache2" >> -D SUEXEC_BIN="/usr/lib/apache2/suexec" >> -D DEFAULT_PIDLOG="/var/run/apache2.pid" >> -D DEFAULT_SCOREBOARD="logs/apache_runtime_status" >> -D DEFAULT_LOCKFILE="/var/run/apache2/accept.lock" >> -D DEFAULT_ERRORLOG="logs/error_log" >> -D AP_TYPES_CONFIG_FILE="mime.types" >> -D SERVER_CONFIG_FILE="apache2.conf" >> >> *mod_wsgi version* >> ii libapache2-mod-wsgi 3.3-4ubuntu0.2 >> Python WSGI adapter module for Apache >> >> *Python version:* 2.7.3 >> >> -- >> You received this message because you are subscribed to the Google Groups >> "modwsgi" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To post to this group, send email to [email protected]. >> Visit this group at http://groups.google.com/group/modwsgi. >> For more options, visit https://groups.google.com/d/optout. >> >> >> > -- > You received this message because you are subscribed to the Google Groups > "modwsgi" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] <javascript:>. > To post to this group, send email to [email protected] <javascript:> > . > Visit this group at http://groups.google.com/group/modwsgi. > For more options, visit https://groups.google.com/d/optout. > > > -- You received this message because you are subscribed to the Google Groups "modwsgi" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/modwsgi. For more options, visit https://groups.google.com/d/optout.
