我一直在研究许多类似的问题,但是似乎没有适合我的解决方案,所以我将其发布在这里。
我不知道如何解决该错误:
“从守护进程收到的响应头被截断或过大”
我的服务器配置:
我收到的确切错误日志是:
[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帖子,所以我希望它足够详细,让我知道是否不是:)
答案 0 :(得分:0)
对不起,您的回复很晚,但是我遇到了同样的问题,因此我遵循了此解决方案并为我工作。 https://stackoverflow.com/a/56753895/8569520
在我的情况下,问题出在psycopg2版本上,我将其更新为最新版本,并且可以正常工作
答案 1 :(得分:0)
我尽了一切建议。没有结果。原因是mysql.connector。用pymysql代替它。没关系。
答案 2 :(得分:0)
我在使用 Apache 2.4、MariaDB 10.5、mod_wsgi 4.9、Python 3.9.6、Flask 2.0.1 和 mysql-connector 2.2.9 在 Fedora 34 上检索 MySQL 查询结果时遇到了这个问题。
为了解决这个问题,我必须在虚拟主机配置中设置 WSGIDaemonProcess header-buffer-size
参数。
这个参数的默认值是32768字节,所以我增加了。
WSGIDaemonProcess 文档:
https://modwsgi.readthedocs.io/en/master/configuration-directives/WSGIDaemonProcess.html