【发布时间】:2017-11-08 17:55:36
【问题描述】:
我搜索并阅读了许多网站,包括 stackoverflow 上的大多数相关文章,但我不知道如何解决该错误:
“从守护进程收到的截断或过大的响应标头”
此服务器出现故障:
- Apache 2.2.15
- mod_wsgi 4.4.13
此服务器运行相同的代码而没有截断问题:
- Apache 2.4.6
- mod_wsgi 3.4
不幸的是,我没有选择升级 Apache 或降级 mod_wsgi 以使其工作。我试过改变 header-buffer-size,但它似乎没有做任何事情(仍然失败):
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 设置为信息:
[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/
【问题讨论】:
-
您是否尝试像大多数答案所建议的那样设置
WSGIApplicationGroup %{GLOBAL},因为主要原因是守护进程崩溃。确保您将 Apache 中的LogLevel设置为至少info,因为 mod_wsgi 将记录更多有关进程可能重新启动的原因。 -
嗨,格雷厄姆,是的,这是我尝试的第一件事。清理完之后,我会将我的 apache wsgi.conf 发布在我的原始帖子中。也许我遗漏了一些东西或在错误的位置。感谢您的回复!
-
我将 apache 的 wsgi_ssl.conf 和 LogLevel 设置为 info 后都添加了。
-
将
info用于LogLevel时,在来自mod_wsgi 的有关进程重新启动的截断或过大响应标头的消息之后是否有任何内容?日志文件中给出pid的进程是否还存在?如果您有站点范围的日志文件以及 Apache 的虚拟主机特定日志文件,请检查站点范围的日志文件。 -
我能够解决这个问题。我开始梳理代码,发现由于某种原因导致截断错误的 pandas groupby 语句。数据框中有几行不想分组为 0 值。我把它们过滤掉了,它起作用了。我没想到会看到与问题类型有关的截断错误,所以它让我走错了排除故障的道路。格雷厄姆,感谢您的帮助,很抱歉浪费了您的时间!