Reputation: 14311
I'm having a problem getting Apache to reply properly. I'm getting a browser error: Gateway Timeout: The gateway did not receive a timely response from the upstream server or application.
I know the application is connecting through mod_wsgi to the Django layer, as I've verified queries are occurring in PostgreSQL when the connection occurs, from the Wagtail CMS's middleware running.
The system is running RHEL 7.1, Apache 2.4.6, and mod_wsgi 4.4.21 with Python 3.4 and Django 1.8.
Here's the error in the Apache log:
[Thu Jan 07 13:25:54.554395 2016] [wsgi:error] [pid 17128] [client 128.91.91.123:50664] Timeout when reading response headers from daemon process 'my_classroom-https': /var/www/html/my_classroom/my_classroom/wsgi.py
Here's wsgi.py:
import os, sys
from socket import gethostname
from django.core.wsgi import get_wsgi_application
sys.path.append(os.sep.join(os.path.abspath(__file__).split(os.sep)[:-2]))
# cpl == Core, Production, Linux..
if(gethostname()[:3]) == 'cpl':
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "my_classroom.settings.prod")
# csl == Core, Staging, Linux.
elif(gethostname()[:3]) == 'csl':
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "my_classroom.settings.stage")
# else use dev settings.
# cdl == Core, Development, Linux. vag == Vagrant.
else:
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "my_classroom.settings.dev")
application = get_wsgi_application()
And here's the relevant portion of the Apache config:
LoadModule wsgi_module modules/mod_wsgi.so
LoadModule ssl_module modules/mod_ssl.so
WSGISocketPrefix /var/run/wsgi
NameVirtualHost *:443
Listen 443
<VirtualHost *:443>
ServerName my-python-dev.school.edu
ErrorLog /var/www/logs/classroom-apache-errors.log
SSLENGINE on
SSLCertificateFile /etc/pki/tls/certs/localhost.crt
SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
SSLProtocol all -SSLv2
WSGIApplicationGroup %{GLOBAL}
WSGIDaemonProcess my_classroom-https python-home=/var/www/virtualenvs/my_classroom request-timeout=600
WSGIScriptAlias /classroom /var/www/html/my_classroom/my_classroom/wsgi.py process-group=my_classroom-https
WSGIProcessGroup my_classroom-https
Alias /classroom/static/ /var/www/html/my_classroom/static/
LogLevel info
</VirtualHost>
I've tried a few few things, including increasing the request-timeout
parameter of the WSGIDaemonProcess directive to be 600 seconds instead of 60, but it still seems to timeout right around 60 seconds.
Any ideas or help would be greatly appreciated. Thanks.
Upvotes: 4
Views: 9273
Reputation: 14311
I got this working. The problem was a secondary database definition (not default
) which couldn't connect to the server. There was no indication of this anywhere in the logs, unfortunately. This is a tough error to debug.
Here's some steps I'd take next time I see this error:
telnet mypostgresserver.domain.com 5432
, telnet ldap.myprivate.network 636
), and that they're not hanging.Upvotes: 2