Nginx is sending duplicate headers "Content-Length" and "Connection"

peps03

Verified User
Joined
Oct 24, 2013
Messages
191
Location
Amsterdam
Nginx is sending duplicate headers "Content-Length" and "Connection"

Server configuration: CentOS 7, Apache 2.4.17, PHP 5.6.16, NginX 1.8.0 as reverse proxy, mod_security and rules latest version and DirectAdmin 1.49.1.

The problem is: nginx is sending "Content-Length" and "Connection" headers twice per request. I have tried add to proxy_hide_header Content-Length to /etc/nginx/nginx-vhosts.conf but that didn't help. Googling (much) didn't get me any further.

How can i remove these double headers? Help much appreciated!
 
May you post complete headers here to see what we're talking about?
 
Status: HTTP/1.1 200 OK
Server: nginx
Date: Thu, 10 Dec 2015 23:10:20 GMT
Content-Length: 44
Connection: close
X-Accel-Version: 0.01
Last-Modified: Wed, 28 Oct 2015 22:29:13 GMT
ETag: "2c-52331b9531d48"
Accept-Ranges: bytes
Vary: User-Agent
Content-Type: text/html
Content-Length: 44
Connection: close
Content (0.04 KiB)
 
I was not able to reproduce that. Try disabling ModSecurity and see if it solves the issue.
 
Thanks for your reply.
How would you advise to temporary disable mod_security?
Would it be enough, when logged-in as admin, to navigate to > Plugin: Comodo WAF 2.14 > Security Engine > Security Engine: Off ?
 
To disable it:
Code:
cd /usr/local/directadmin/custombuild
./build set modsecurity no
./build nginx

To enable again:
Code:
cd /usr/local/directadmin/custombuild
./build set modsecurity yes
./build nginx
 
Just to be sure, i use nginx as reverse proxy in combination with apache 2.4.
./ build nginx is correct then?
 
Yes, it's still correct :) Because "./build nginx_apache" = "./build apache" + "./build nginx".
 
Thanks smtalk! That worked. Headers are now "normal" again:

Status: HTTP/1.1 200 OK
Server: nginx
Date: Mon, 14 Dec 2015 20:58:36 GMT
Content-Type: text/html
Transfer-Encoding: chunked
Connection: close
Vary: Accept-Encoding
X-Accel-Version: 0.01
Last-Modified: Mon, 14 Dec 2015 20:55:17 GMT
ETag: W/"2b-526e1e3ea41a1"
Vary: User-Agent
Content-Encoding: gzip

But now the question, how can I enable mod_security again and prevent it from sending these double headers again? Any idea?

*edit: And the thing is, this double header issue just occurred about 1-1,5 and a half weeks ago. Maybe because one of the Comodo rule-set or mod_security updates? (Btw i use the Custombuild 2.0 plugin to manage it.)
 
Last edited:
Back
Top