如何解决:从守护进程

时间:2017-06-07 11:40:21

标签: python apache mod-wsgi

我用谷歌搜索并阅读了很多网站,包括stackoverflow上的大部分相关文章,我无法弄清楚如何解决这个错误:

“从守护进程收到的截断或超大响应标头”

此服务器失败:

  • Apache 2.2.15
  • mod_wsgi 4.4.13

此服务器运行相同的代码而没有截断的问题:

  • Apache 2.4.6
  • mod_wsgi 3.4

不幸的是,我没有选择升级Apache或降级mod_wsgi以使其工作。我已经尝试更改header-buffer-size,但它似乎没有做任何事情(仍然失败):

http://modwsgi.readthedocs.io/en/develop/configuration-directives/WSGIDaemonProcess.html?highlight=truncated

  

header-buffer-size = nnn定义响应的最大大小   header / value可以是从WSGI应用程序返回的。该   默认大小为32768字节。这可能需要覆盖在哪里   返回过大的响应标头,例如在自定义中   使用WWW-Authenticate的身份验证挑战方案   报头中。

有关如何解决这个问题的想法吗?

Chrome开发者工具输出

响应标题:

HTTP/1.1 500 Internal Server Error Date: Wed, 07 Jun 2017 11:49:58 GMT
Server: Apache/2.2.15 (Red Hat) Content-Length: 644 Connection: close
Content-Type: text/html; charset=iso-8859-1 Request Headers view
source

请求标题:

    Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate, sdch, br
Accept-Language:en-US,en;q=0.8
Authorization:Basic 999999ZXQ0Myo=
Cache-Control:no-cache
Connection:keep-alive
Host:removed.the.url.for.security
Pragma:no-cache
Referer:https://removed.the.url.for.security/TeamStats/provstats/
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36

已编辑的wsgi_ssl.conf文件:

#get warning, already loaded
#LoadModule ldap_module modules/mod_ldap.so
#LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
LoadModule ssl_module modules/mod_ssl.so
LoadModule wsgi_module modules/mod_wsgi.so
LoadModule php5_module modules/libphp5.so
WSGISocketPrefix /var/run/wsgi
SSLPassPhraseDialog  builtin
SSLSessionCache         shmcb:/var/cache/mod_ssl/scache(512000)
SSLSessionCacheTimeout  300
SSLMutex default
SSLRandomSeed startup file:/dev/urandom  256
SSLRandomSeed connect builtin
SSLCryptoDevice builtin
LDAPVerifyServerCert off
LDAPSharedCacheSize 500000
LDAPCacheEntries 1024
LDAPCacheTTL 600
LDAPOpCacheEntries 1024
LDAPOpCacheTTL 600
LDAPConnectionTimeout 5

Listen 443
<VirtualHost *:443>
    TimeOut 120

    ServerName server.name.address:443
    ServerAdmin admin@address.com

    SSLEngine on
    SSLProtocol all -SSLv2
    SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
    SetEnvIf User-Agent ".*MSIE.*" \
      nokeepalive ssl-unclean-shutdown \
      downgrade-1.0 force-response-1.0

    SSLCertificateFile /etc/pki/tls/certs/cert.crt
    SSLCertificateKeyFile /etc/pki/tls/private/cert.key
    SSLCertificateChainFile /etc/pki/tls/certs/cert.pem

    LogLevel error
    CustomLog /var/log/access_log combined
    ErrorLog /var/log/error_log

    WSGIPassAuthorization On
    WSGIApplicationGroup %{GLOBAL}

    DocumentRoot /var/www/html/documents
    <Directory /var/www/html/documents>
        Order allow,deny
        Allow from all
    </Directory>

    AddType text/html .php
    DirectoryIndex index.html index.php

    <FilesMatch \.php$>
        SetHandler application/x-httpd-php
    </FilesMatch>

    <Location />
        Order allow,deny
        Allow from all

        AuthType Basic
        AuthBasicProvider ldap
        AuthName "test name"
        AuthzLDAPAuthoritative on

        AuthLDAPURL "ldaps://address and parameters here"

        AuthLDAPBindDN "parameters here"
        AuthUserFile /dev/null
        AuthLDAPBindPassword password
        AuthLDAPRemoteUserAttribute sAMAccountName

        SSLRequireSSL
        Satisfy any
        #Require valid-user
    </Location>

    WSGIDaemonProcess test display-name=test threads=25 header-buffer-size=65536 inactivity-timeout=300
    WSGIScriptAlias /test /var/www/html/wsgi-scripts/test.wsgi process-group=test
    Alias /test/static /var/www/html/documents/test/static
    <Location /test>
        WSGIProcessGroup test
        Require ldap-user "username"
        Order deny,allow
        Deny from all
   </Location>
</VirtualHost>

LogLevel设置为info:

[Thu Jun 08 11:33:58 2017] [info] [client 0.0.0.0] mod_wsgi (pid=33568, process='test', application=''): Loading WSGI script '/var/www/html/wsgi-scripts/test.wsgi'.
[Thu Jun 08 11:34:07 2017] [error] [client 0.0.0.0] Truncated or oversized response headers received from daemon process 'test': /var/www/html/wsgi-scripts/test.wsgi, referer: https://url.address.net/test/

1 个答案:

答案 0 :(得分:0)

在我的情况下,我使用aws EC2和eb服务器,并显示相同的错误消息。经过详细检查,我发现这只是简单的内存错误。当我扩展我的实例时,问题就解决了。

official page开始,在Elastic Beanstalk控制台中配置EC2实例:

  1. 打开Elastic Beanstalk控制台。
  2. 导航到您所在环境的管理页面。
  3. 选择配置。
  4. 在Instances配置卡上,选择Modify
  5. 我尝试过上面列出的方法来解决问题,在03_scipy.config文件中添加以下代码并将其保存到.ebextension目录。但是,它没有用。

    container_commands:  
      AddGlobalWSGIGroupAccess: 
        command: "if ! grep -q 'WSGIApplicationGroup %{GLOBAL}' ../wsgi.conf ; then echo 'WSGIApplicationGroup %{GLOBAL}' >> ../wsgi.conf; fi;"