title: How to resolve: Truncated or oversized response headers received from daemon process
body: <p>I've googled and read through a number of sites, including most of the related articles here at stackoverflow and I can't figure out how to get around the error:</p>
  
  <p><strong><em>"Truncated or oversized response headers received from daemon process "</em></strong></p>
  
  <p><strong>This server fails:</strong></p>
  
  <ul>
  <li>Apache 2.2.15</li>
  <li>mod_wsgi 4.4.13</li>
  </ul>
  
  <p><strong>This server runs the same code without the truncated issue:</strong></p>
  
  <ul>
  <li>Apache 2.4.6</li>
  <li>mod_wsgi 3.4</li>
  </ul>
  
  <p>Unfortunately, I don't have the option of upgrading Apache or downgrading mod_wsgi to get it to work. I've tried changing the header-buffer-size, but it doesn't seem to do anything (still fails): </p>
  
  <p><a href="http://modwsgi.readthedocs.io/en/develop/configuration-directives/WSGIDaemonProcess.html?highlight=truncated" rel="nofollow noreferrer">http://modwsgi.readthedocs.io/en/develop/configuration-directives/WSGIDaemonProcess.html?highlight=truncated</a></p>
  
  <blockquote>
    <p>header-buffer-size=nnn Defines the maximum size that a response
    header/value can be that is returned from a WSGI application. The
    default size is 32768 bytes. This might need to be overridden where
    excessively large response headers are returned, such as in custom
    authentication challenge schemes which use the WWW-Authenticate
    header.</p>
  </blockquote>
  
  <p>Any thoughts about how to fix this?</p>
  
  <p><strong>Chrome Dev Tools output:</strong></p>
  
  <p><strong>Response Headers:</strong></p>
  
  <pre><code>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
  </code></pre>
  
  <p><strong>Request Headers:</strong></p>
  
  <pre><code>    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
  </code></pre>
  
  <p><strong>Edited wsgi_ssl.conf file:</strong></p>
  
  <pre><code>#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
  &lt;VirtualHost *:443&gt;
      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
      &lt;Directory /var/www/html/documents&gt;
          Order allow,deny
          Allow from all
      &lt;/Directory&gt;
  
      AddType text/html .php
      DirectoryIndex index.html index.php
  
      &lt;FilesMatch \.php$&gt;
          SetHandler application/x-httpd-php
      &lt;/FilesMatch&gt;
  
      &lt;Location /&gt;
          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
      &lt;/Location&gt;
  
      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
      &lt;Location /test&gt;
          WSGIProcessGroup test
          Require ldap-user "username"
          Order deny,allow
          Deny from all
     &lt;/Location&gt;
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p><strong>LogLevel set to info:</strong></p>
  
  <pre><code>[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/
  </code></pre>