守护程序模式下响应头被截断或过大

时间:2019-02-05 11:24:47

标签: flask mod-wsgi wsgi

我在Flask网站上出现了一个奇怪的错误。

重要提示:第​​一页(表单)正在运行,但是当我提交时,我有一个505。

我尝试了StackOverflow的一些问题:),但找不到解决方案。

这里是日志:

Mon Feb 25 09:17:37.863313 2019] [wsgi:info] [pid 30874:tid 140525377849088] [remote 192.168.56.1:61092] mod_wsgi (pid=30874, process='flask_my_app', application=''): Loading WSGI script '/var/www/my_app/my_app/flask_my_app/flask_my_app.wsgi'.
[Mon Feb 25 09:17:38.191855 2019] [wsgi:error] [pid 30874:tid 140525377849088] /home/vagrant/.virtualenvs/my_app/lib/python2.7/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
[Mon Feb 25 09:17:38.191899 2019] [wsgi:error] [pid 30874:tid 140525377849088]   """)
[Mon Feb 25 09:17:44.995445 2019] [wsgi:error] [pid 30781:tid 140525239768832] [client 192.168.56.1:3595] Truncated or oversized response headers received from daemon process 'flask_my_app': /var/www/my_app/my_app/flask_my_app/flask_my_app.wsgi, referer: http://vm.my_app/

==> /var/log/apache2/error.log <==
[Mon Feb 25 09:17:45.562808 2019] [core:notice] [pid 30767:tid 140525508945792] AH00051: child pid 30874 exit signal Segmentation fault (11), possible coredump in /etc/apache2

==> /var/log/apache2/my_app-error.log <==
[Mon Feb 25 09:17:45.589899 2019] [wsgi:info] [pid 30956:tid 140525508945792] mod_wsgi (pid=30956): Attach interpreter ''.
[Mon Feb 25 09:17:45.591070 2019] [wsgi:info] [pid 30956:tid 140525508945792] mod_wsgi (pid=30956): Adding '/var/www/my_app/my_app' to path.
[Mon Feb 25 09:17:45.595458 2019] [wsgi:info] [pid 30956:tid 140525508945792] mod_wsgi (pid=30956): Adding '/home/vagrant/.virtualenvs/my_app/lib/python2.7/site-packages' to path.
[Mon Feb 25 09:17:45.608611 2019] [wsgi:info] [pid 30956:tid 140525377849088] [remote 192.168.56.1:61092] mod_wsgi (pid=30956, process='flask_my_app', application=''): Loading WSGI script '/var/www/my_app/my_app/flask_my_app/flask_my_app.wsgi'.
[Mon Feb 25 09:17:45.916197 2019] [wsgi:error] [pid 30956:tid 140525377849088] /home/vagrant/.virtualenvs/my_app/lib/python2.7/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
[Mon Feb 25 09:17:45.916224 2019] [wsgi:error] [pid 30956:tid 140525377849088]   """)

我在Apache 2.7中的虚拟主机在这里:

<VirtualHost *:80>
       ServerName vm.my_app
       ServerAlias vm.my_app
       DocumentRoot /var/www/my_app/my_app

       LogLevel info

       WSGIDaemonProcess flask_my_app python-path=/var/www/my_app/my_app:/home/vagrant/.virtualenvs/my_app/lib/python2.7/site-packages display-name=%{GROUP}
        WSGIProcessGroup flask_my_app
        WSGIScriptAlias / /var/www/my_app/my_app/flask_my_app/flask_my_app.wsgi
        WSGIApplicationGroup %{GLOBAL}

        #Alias /favicon.ico /var/www/my_app/my_app/static/favicon.ico
        Alias /site_media/ /var/www/my_app/my_app/site_media/
        Alias /media/ /var/www/my_app/my_app/media/
        Alias /static/ /var/www/my_app/my_app/static/
        AliasMatch /([/]*\.css) /var/www/my_app/my_app/static/css/$1

        <Directory /var/www/my_app/my_app>
            Order allow,deny
            Allow from all
            Require all granted
        </Directory>

        <Directory /var/www/my_app/my_app/flask_my_app>
            Order allow,deny
            Allow from all
            Require all granted
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/my_app-error.log
        CustomLog ${APACHE_LOG_DIR}/my_app-access.log combined
</VirtualHost>

python版本是2.7.12,我使用“虚拟环境包装器”。

我认为wsgi模块的版本很旧:

lrwxrwxrwx 1 root root   15 mai    3  2016 mod_wsgi.so -> mod_wsgi.so-2.7*
-rwxrwxrwx 1 root root 223K mai    3  2016 mod_wsgi.so-2.7*

wsgi文件是“经典”文件,而requirements.txt文件是:

$ cat ../requirements.txt
click==6.7
Flask==1.0.2
Flask-Assets==0.12
Flask-Caching==1.4.0
Flask-Login==0.4.1
Flask-SQLAlchemy==2.3.2
Flask-WTF==0.14.2
itsdangerous==0.24
Jinja2==2.10
MarkupSafe==1.0
pbr==5.1.1
psycopg2==2.7.5
six==1.12.0
SQLAlchemy==1.2.8
stevedore==1.30.0
webassets==0.12.1
Werkzeug==0.14.1
WTForms==2.2.1

异体抗体可以帮助我吗?

非常感谢

F。

1 个答案:

答案 0 :(得分:0)

对其他人也许有用,我的问题已通过取消激活postgresql.conf中的SSL支持!!!来解决:

80 ssl = off               # (change requires restart)

日志:

==> /var/log/postgresql/postgresql-9.6-main.log <==
2019-03-07 15:28:28.573 CET [5346] [unknown]@[unknown] LOG:  could not accept SSL connection: EOF detected