【发布时间】:2019-03-19 16:03:04
【问题描述】:
我一直在寻找许多类似的问题,但似乎没有适合我的问题的解决方案,所以我在这里发布。
我不知道如何解决这个错误:
“从守护进程收到的截断或过大的响应标头”
我的服务器配置:
- Apache 2.4.34 (Ubuntu)
- mod_wsgi 4.5.17
- OpenSSL 1.1.1
- Python 3.6
我收到的确切错误日志是:
[Tue Mar 19 15:14:43.666649 2019] [wsgi:info] [pid 7988] mod_wsgi (pid=7988): Initializing Python.
[Tue Mar 19 15:14:43.684932 2019] [ssl:info] [pid 7945] [client X.X.X.X:X] AH01964: Connection to child 1 established (server app.com:443)
[Tue Mar 19 15:14:43.762255 2019] [wsgi:info] [pid 7988] mod_wsgi (pid=7988): Attach interpreter ''.
[Tue Mar 19 15:14:43.836994 2019] [ssl:info] [pid 7946] [client X.X.X.X:X] AH01964: Connection to child 2 established (server neuralytics.ai:443)
[Tue Mar 19 15:14:43.967857 2019] [wsgi:error] [pid 7947] [client X.X.X.X:X] Truncated or oversized response headers received from daemon process 'flaskapi': /path/to/subdomain/flaskapp.wsgi, referer: https://subdomain.app.com/register
如您所见,LogLevel 设置为 info。
flaskapp.wsgi:
#!/usr/bin/python3
activate_this = '/var/subdomain/app.com/public/path/to/my/virtualenv/bin/activate_this.py'
exec(open(activate_this).read())
import sys
import logging
logging.basicConfig(stream=sys.stderr)
path = '/var/subdomain/app.com/public/path/to/flask'
if path not in sys.path:
sys.path.append(path)
from main import app as application
application.secret_key = '****'
.conf 文件 处理多个子域。最重要的部分与 subdomain.app.com 相关:
#WSGIPythonPath /usr/bin/python3
<IfModule mod_ssl.c>
<VirtualHost *:443>
[...]
ServerName app.com
ServerAlias www.app.com
[...]
</VirtualHost>
<VirtualHost *:443>
ServerName subdomain.app.com
DocumentRoot /var/subdomain/app.com/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ServerAlias subdomain.app.com
Include /etc/letsencrypt/options-ssl-apache.conf
WSGIDaemonProcess flaskapi python-path=/var/subdomain/app.com/public/:/var/subdomain/app.com/public/path/to/my/virtualenv/lib/python3.6/site-packages/
WSGIProcessGroup flaskapi
WSGIScriptAlias / /var/subdomain/app.com/public/flaskapp.wsgi
WSGIApplicationGroup %{GLOBAL}
<Directory /var/subdomain/app.com/public>
Require all granted
</Directory>
Alias /static/ /var/subdomain/app.com/public/production/static/
<Directory /var/api/neuralytics.ai/public/production/static/>
Require all granted
</Directory>
SSLCertificateFile /etc/letsencrypt/live/app.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/app.com/privkey.pem
</VirtualHost>
</IfModule>
响应标头的 Chrome 开发输出:
HTTP/1.1 500 Internal Server Error
Date: Tue, 19 Mar 2019 15:25:58 GMT
Server: Apache/2.4.34 (Ubuntu)
Content-Length: 627
Connection: close
Content-Type: text/html; charset=iso-8859-1
请求标头的 Chrome 开发人员输出:
POST /register HTTP/1.1
Host: subdomain.app.com
Connection: keep-alive
Content-Length: 164
Origin: https://subdomain.app.com
X-CSRFToken: *******
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36
Content-Type: application/json;charset=UTF-8
Accept: */*
Referer: https://subdomain.app.com/register
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9,fr;q=0.8,es;q=0.7
Cookie: session=******
你们中有人知道如何解决这个问题吗? 这也是我的第一篇 stackoverflow 帖子,所以我希望这足够详细,如果不是,请告诉我:)
【问题讨论】: