我在让Apache正确回复时遇到问题。我收到浏览器错误:Gateway Timeout: The gateway did not receive a timely response from the upstream server or application.
我知道应用程序通过mod_wsgi连接到Django层,因为我已经验证了连接发生时PostgreSQL中的查询,来自Wagtail CMS的中间件运行。
系统正在使用Python 3.4和Django 1.8运行RHEL 7.1,Apache 2.4.6和mod_wsgi 4.4.21。
以下是Apache日志中的错误:
[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
这是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()
这是Apache配置的相关部分:
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>
我尝试了一些事情,包括将WSGIDaemonProcess指令的request-timeout
参数增加到600秒而不是60秒,但它似乎仍然在60秒左右超时。
任何想法或帮助将不胜感激。感谢。
答案 0 :(得分:2)
我得到了这个工作。问题是辅助数据库定义(不是default
),它无法连接到服务器。不幸的是,日志中没有任何迹象表明这一点。这是一个难以调试的错误。
以下是我在下次看到此错误时采取的一些步骤:
telnet mypostgresserver.domain.com 5432
,telnet ldap.myprivate.network 636
)所需的所有服务,并且他们不会挂起。