Further investigation shown that nginx and apache differently handle half-open connections. Bellow is simple in perl to reproduce problem. Problem is caused by shutdown call on client
use IO::Socket::INET;
my $host = "www.server";
my $sock = IO::Socket::INET->new(
PeerAddr => $host,
PeerPort => 'http(80)',
Proto => 'tcp'
);
unless ($sock) { die "cannot connect\n" }
$sock->autoflush(0);
print $sock "HEAD / HTTP/1.1\r\n";
print $sock "Host: ".$host."\r\n";
print $sock "Accept: */*\r\n";
print $sock "Accept-Encoding: identity\r\n";
print $sock "Connection: close\r\n\r\n";
$sock->autoflush(1);
# shutdown call creates problems
# if commented works for nginx and apache
# if uncomented works only with apache
shutdown($sock, 1);
while (my $line = <$sock>) {
$line =~ s/[\r\n]$//;
print $line."\n"; }
close $sock;