Nginx fails to deliver certain files with gzip + SSL

I’ve noticed a problem with nginx 0.6.x running with gzip and SSL.
Some static file delivery is cut off half way. This file always
breaks, for example:

http://prototypejs.org/assets/2007/10/16/prototype.js

Here is the relevant nginx config:

gzip on;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_proxied any;
gzip_types text/plain text/html text/css application/x-
javascript text/xml application/xml application/xml+rss text/javascript;

server {

root /Users/joshua/ssl-test;
listen 443;
ssl on;

path to your certificate

ssl_certificate /Users/joshua/.ssl/server.crt;

path to your ssl key

ssl_certificate_key /Users/joshua/.ssl/server.key;
}


Joshua Sierles
[email protected]
(866) 518-9273 x214

On Mon, Oct 29, 2007 at 10:54:39AM +0100, Joshua Sierles wrote:

gzip_comp_level 2;
ssl_certificate /Users/joshua/.ssl/server.crt;

path to your ssl key

ssl_certificate_key /Users/joshua/.ssl/server.key;
}

Could you make debug log of this request ?

./configure --with-debug …

nginx.conf:
error_log /path/to/log debug;

With debugging turned on, this request hangs halfway, then after 20
seconds we get a 408:

2007/10/29 16:40:40 [debug] 13151#0: *7 event timer del: 11: 3966499952
2007/10/29 16:40:40 [debug] 13151#0: *7 http writer handler: “/
prototype.js?”
2007/10/29 16:40:40 [info] 13151#0: *7 client timed out (60:
Operation timed out) while sending response to client, client:
127.0.0.1, server: joshuas-computer.local, URL: “/prototype.js”,
host: “localhost”
2007/10/29 16:40:40 [debug] 13151#0: *7 http finalize request: 408, “/
prototype.js?”
2007/10/29 16:40:40 [debug] 13151#0: *7 http close request
2007/10/29 16:40:40 [debug] 13151#0: *7 http log handler
2007/10/29 16:40:40 [debug] 13151#0: *7 run cleanup: 0180D360, fd:15
2007/10/29 16:40:40 [debug] 13151#0: *7 run cleanup: 0180D324, fd:12
2007/10/29 16:40:40 [debug] 13151#0: *7 free: 01811800
2007/10/29 16:40:40 [debug] 13151#0: *7 free: 01810800
2007/10/29 16:40:40 [debug] 13151#0: *7 free: 0180DC00
2007/10/29 16:40:40 [debug] 13151#0: *7 free: 0180EC00
2007/10/29 16:40:40 [debug] 13151#0: *7 free: 00605000
2007/10/29 16:40:40 [debug] 13151#0: *7 free: 004EB000
2007/10/29 16:40:40 [debug] 13151#0: *7 free: 0180CC00, unused: 528
2007/10/29 16:40:40 [debug] 13151#0: *7 close http connection: 11
2007/10/29 16:40:40 [debug] 13151#0: *7 SSL_shutdown: 1
2007/10/29 16:40:40 [debug] 13151#0: *7 free: 01802E00
2007/10/29 16:40:40 [debug] 13151#0: *7 free: 00487000
2007/10/29 16:40:40 [debug] 13151#0: *7 free: 01810400
2007/10/29 16:40:40 [debug] 13151#0: *7 free: 01109530, unused: 28
2007/10/29 16:40:40 [debug] 13151#0: *7 free: 01109F60, unused: 172

Joshua Sierles
[email protected]
(866) 518-9273 x214

On Mon, Oct 29, 2007 at 04:41:45PM +0100, Joshua Sierles wrote:

2007/10/29 16:40:40 [debug] 13151#0: *7 http finalize request: 408, "/
2007/10/29 16:40:40 [debug] 13151#0: *7 free: 004EB000
2007/10/29 16:40:40 [debug] 13151#0: *7 free: 0180CC00, unused: 528
2007/10/29 16:40:40 [debug] 13151#0: *7 close http connection: 11
2007/10/29 16:40:40 [debug] 13151#0: *7 SSL_shutdown: 1
2007/10/29 16:40:40 [debug] 13151#0: *7 free: 01802E00
2007/10/29 16:40:40 [debug] 13151#0: *7 free: 00487000
2007/10/29 16:40:40 [debug] 13151#0: *7 free: 01810400
2007/10/29 16:40:40 [debug] 13151#0: *7 free: 01109530, unused: 28
2007/10/29 16:40:40 [debug] 13151#0: *7 free: 01109F60, unused: 172

I need whole log of the request. Could send it to my address ?

Igor,

Thanks, that seems to work great. What exactly was the problem?

Joshua Sierles
[email protected]
(866) 518-9273 x214

On Mon, Oct 29, 2007 at 10:54:39AM +0100, Joshua Sierles wrote:

gzip_comp_level 2;
ssl_certificate /Users/joshua/.ssl/server.crt;

path to your ssl key

ssl_certificate_key /Users/joshua/.ssl/server.key;
}

Try the attached patch.

Hi Agustin,

We use nginx 0.5.31 for a heavily used application the uploads in
excess of 10Gb a day, we’ve had no issues besides the usual issues of
downstream proxy servers and people who have unrealistic expectations
about the time it takes for things to upload.

What OS is nginx running on ?

What browser and version have you tried on the macs that fail ? Are
they local to your web server or in a remote location?

What do you get in your errorlog?

Cheers

Dave

Hi!

We are using nginx (both 0.5.32 and 0.6.16) and all is Ok except one
problem.
When we upload files with Macs (our users use last OSX), many times the
file is
not sent. The status of browser remains in “sending”.

Any pointer?

Thanks,
Agustin

On Mon, Oct 29, 2007 at 09:00:45PM +0100, Joshua Sierles wrote:

Thanks, that seems to work great. What exactly was the problem?

Try the new correct patch. The previous should be rolled back.

On 10/30/07, Agustin L. [email protected] wrote:

We are using nginx (both 0.5.32 and 0.6.16) and all is Ok except one
problem.
When we upload files with Macs (our users use last OSX), many times the
file is
not sent. The status of browser remains in “sending”.

Safari is notoriously buggy at file uploads. It will hang, as you say,
appearing to be sending, but will never complete. It’s a browser
problem, and happens with Lighttpd as well. I don’t know of a
workaround.

Alexander.