Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#542 closed defect (fixed)

NGINX won't use gzip_static when http request is proxied by NGINX and the browser is Firefox 28

Reported by: frankbb.pip.verisignlabs.com Owned by:
Priority: minor Milestone:
Component: nginx-core Version: 1.5.x
Keywords: Cc:
uname -a: Linux custodis 3.2.0-4-amd64 #1 SMP Debian 3.2.51-1 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.5.13

Description

We are having an issue with gzip_static in combination with Firefox 28 and SPDY. NGINX doesn't gzip content in one case when i expect NGINX would use gzip_static.

I will use the following file in this example:

$ ll $webroot/mxui/ui/mxui.css*
-rw-r--r-- 1 monere monere 103521 Oct 30  2012 $webroot/mxui/ui/mxui.css
-rw-r--r-- 1 monere monere  17305 Oct 30  2012 $webroot/mxui/ui/mxui.css.gz

1.) NGINX as front-facing web server that proxies to another NGINX, all unrelated config is stripped:

server {
    listen [::]:7000;
    listen 0.0.0.0:7000;
    server_name _;
    root $webroot;
}

upstream xxx {
    server 127.0.0.1:7000;
    keepalive 8;
}

server {
    listen [::]:443;
    listen 0.0.0.0:443;
    server_name $host;
    ssl_certificate [...];
    ssl_certificate_key [...];
    add_header Strict-Transport-Security "max-age=31536000;";
    location / {
        proxy_pass http://xxx/;
        client_max_body_size 1024M;
    }
}

gzip on;
gzip_proxied any;
gzip_disable "msie6";
gzip_types application/json;
gzip_static on;

I tested with three major browsers on a Windows virtual machine, Firefox 28 without SPDY, Internet Explorer 11 and Chrome 34.

http requests that are gzipped, Firefox has SPDY disabled:

$host $remote_addr - - [14/Apr/2014:16:45:07 +0200] "GET /mxui/ui/mxui.css HTTP/1.1" 200 17305 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0" ECDHE-RSA-AES128-GCM-SHA256 TLSv1.2 49 0.000 ""
$host $remote_addr - - [14/Apr/2014:16:46:00 +0200] "GET /mxui/ui/mxui.css HTTP/1.1" 200 17305 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko" ECDHE-RSA-AES128-SHA256 TLSv1.2 51 0.001 ""
$host $remote_addr - - [14/Apr/2014:16:47:55 +0200] "GET /mxui/ui/mxui.css HTTP/1.1" 200 17305 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36" ECDHE-RSA-AES128-GCM-SHA256 TLSv1.2 57 0.000 ""

http request that is not gzipped, this is when SPDY is enabled:

$host $remote_addr - - [14/Apr/2014:17:00:16 +0200] "GET /mxui/ui/mxui.css HTTP/1.1" 200 103521 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0" ECDHE-RSA-AES128-GCM-SHA256 TLSv1.2 1 0.013 ""

Response header of not working request with Firefox 28.0:

Accept-Ranges			bytes
Content-Length			103521
Content-Type			text/css
Date				Mon, 14 Apr 2014 15:00:16 GMT
Etag				"508fe716-19461"
Last-Modified			Tue, 30 Oct 2012 14:41:26 GMT
Server				nginx
X-Firefox-Spdy			3.1
strict-transport-security	max-age=31536000;

2.) When i add text/css to gzip_types the data is getting gzipped with Firefox 28 and SPDY is enabled:

- gzip_types application/json;
+ gzip_types application/json text/css;

http request:

$host $remote_addr - - [14/Apr/2014:16:53:12 +0200] "GET /mxui/ui/mxui.css HTTP/1.1" 200 22627 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0" ECDHE-RSA-AES128-GCM-SHA256 TLSv1.2 5 0.000 ""
Response headers:
Content-Encoding		gzip
Content-Type			text/css
Date				Mon, 14 Apr 2014 14:58:44 GMT
Last-Modified			Tue, 30 Oct 2012 14:41:26 GMT
Server				nginx
X-Firefox-Spdy			3.1
strict-transport-security	max-age=31536000;

3.) Also when i configure NGINX (Other domain, same server, same config) to serve files directly the content is gzipped by nginx:

gzip on;
gzip_proxied any;
gzip_disable "msie6";
gzip_types application/json;
gzip_static on;

server {
    listen [::]:443;
    listen 0.0.0.0:443;
    server_name $hostname2;
    ssl_certificate [...];
    ssl_certificate_key [...];
    root $webroot2;
}

http request:

$host $remote_addr - - [14/Apr/2014:17:51:43 +0200] "GET /mxui/ui/mxui.css HTTP/1.1" 200 17347 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0" ECDHE-RSA-AES128-GCM-SHA256 TLSv1.2 53 0.000 ""

Response headers:

Content-Encoding		gzip
Content-Length			17347
Content-Type			text/css
Date				Mon, 14 Apr 2014 15:03:57 GMT
Etag				"5177e3c7-43c3"
Last-Modified			Wed, 24 Apr 2013 13:53:11 GMT
Server				nginx
X-Firefox-Spdy			3.1

I would expect that NGINX would use gzip_static in case 1. If you need more information let me know.

Regards,

Frank

Change History (6)

comment:1 by Valentin V. Bartenev, 10 years ago

Resolution: invalid
Status: newclosed

It's known that Firefox doesn't send the Accept-Encoding header over SPDY. Therefore with your configuration the second nginx cannot know that a client supports gzip encoding.

There are two possible solutions:

  1. gzip_static always (but be aware that it will break clients without gzip support unless you have configured gunzip module)
  1. Explicitly set Accept-Encoding for SPDY connections:
map $spdy $accept_encoding {
    default gzip;
    ''      $http_accept_encoding;
}

server {
    location / {
        proxy_pass http://...;
        proxy_set_header Accept-Encoding $accept_encoding;
    }
}

If you think I'm wrong, then please provide a debug log.

comment:2 by frankbb.pip.verisignlabs.com, 10 years ago

You are right about Firefox, in webdeveloper console there is an request header Accept-Encoding gzip, deflate. But according to attached debug this request header is not used by Firefox. But if that is the case why would NGINX serve mxui.css.gz and not mxui.css in case 3?

(I attached debug log of the request i would expect NGINX not to sent a gzip_static file. NGINX config is the same as case 3).

2014/04/15 10:15:10 [debug] 21157#0: *1 delete posted event 0000000001B19D78
2014/04/15 10:15:10 [debug] 21157#0: *1 spdy keepalive handler
2014/04/15 10:15:10 [debug] 21157#0: *1 reusable connection: 0
2014/04/15 10:15:10 [debug] 21157#0: *1 posix_memalign: 0000000001B4FA10:4096 @16
2014/04/15 10:15:10 [debug] 21157#0: *1 spdy read handler
2014/04/15 10:15:10 [debug] 21157#0: *1 SSL_read: 36
2014/04/15 10:15:10 [debug] 21157#0: *1 SSL_read: 415
2014/04/15 10:15:10 [debug] 21157#0: *1 SSL_read: -1
2014/04/15 10:15:10 [debug] 21157#0: *1 SSL_get_error: 2
2014/04/15 10:15:10 [debug] 21157#0: *1 spdy process frame head:80030004 f:0 l:12
2014/04/15 10:15:10 [debug] 21157#0: *1 spdy SETTINGS frame consists of 1 entries
2014/04/15 10:15:10 [debug] 21157#0: *1 spdy SETTINGS entry fl:0 id:7 val:65536
2014/04/15 10:15:10 [debug] 21157#0: *1 spdy process frame head:80030009 f:0 l:8
2014/04/15 10:15:10 [debug] 21157#0: *1 spdy WINDOW_UPDATE sid:0 delta:268369920
2014/04/15 10:15:10 [debug] 21157#0: *1 spdy process frame head:80030001 f:1 l:391
2014/04/15 10:15:10 [debug] 21157#0: *1 spdy SYN_STREAM frame sid:1 prio:2
2014/04/15 10:15:10 [debug] 21157#0: *1 posix_memalign: 0000000001B50A20:4096 @16
2014/04/15 10:15:10 [debug] 21157#0: *1 posix_memalign: 0000000001B51A30:4096 @16
2014/04/15 10:15:10 [debug] 21157#0: *1 spdy process HEADERS 381 of 381
2014/04/15 10:15:10 [debug] 21157#0: *1 malloc: 0000000001BA3200:32768
2014/04/15 10:15:10 [debug] 21157#0: *1 spdy inflateSetDictionary(): 0
2014/04/15 10:15:10 [debug] 21157#0: *1 spdy inflate out: ni:0000000001B633A3 no:0000000001B51BBD ai:0 ao:658 rc:0
2014/04/15 10:15:10 [debug] 21157#0: *1 spdy HEADERS block consists of 8 entries
2014/04/15 10:15:10 [debug] 21157#0: *1 http uri: "/mxui/ui/mxui.css"
2014/04/15 10:15:10 [debug] 21157#0: *1 http args: ""
2014/04/15 10:15:10 [debug] 21157#0: *1 http exten: "css"
2014/04/15 10:15:10 [debug] 21157#0: *1 spdy http request line: "GET /mxui/ui/mxui.css HTTP/1.1"
2014/04/15 10:15:10 [debug] 21157#0: *1 http header: "host: $host"
2014/04/15 10:15:10 [debug] 21157#0: *1 http header: "user-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:28.0) Gecko/20100101 Firefox/28
.0"
2014/04/15 10:15:10 [debug] 21157#0: *1 http header: "accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
2014/04/15 10:15:10 [debug] 21157#0: *1 http header: "accept-language: nl,en-US;q=0.7,en;q=0.3"
2014/04/15 10:15:10 [debug] 21157#0: *1 generic phase: 0
2014/04/15 10:15:10 [debug] 21157#0: *1 rewrite phase: 1
2014/04/15 10:15:10 [debug] 21157#0: *1 test location: "/ws/"
2014/04/15 10:15:10 [debug] 21157#0: *1 test location: "/file"
2014/04/15 10:15:10 [debug] 21157#0: *1 using configuration ""
2014/04/15 10:15:10 [debug] 21157#0: *1 http cl:-1 max:1048576
2014/04/15 10:15:10 [debug] 21157#0: *1 rewrite phase: 3
2014/04/15 10:15:10 [debug] 21157#0: *1 post rewrite phase: 4
2014/04/15 10:15:10 [debug] 21157#0: *1 generic phase: 5
2014/04/15 10:15:10 [debug] 21157#0: *1 generic phase: 6
2014/04/15 10:15:10 [debug] 21157#0: *1 generic phase: 7
2014/04/15 10:15:10 [debug] 21157#0: *1 access phase: 8
2014/04/15 10:15:10 [debug] 21157#0: *1 access phase: 9
2014/04/15 10:15:10 [debug] 21157#0: *1 access phase: 10
2014/04/15 10:15:10 [debug] 21157#0: *1 access phase: 11
2014/04/15 10:15:10 [debug] 21157#0: *1 post access phase: 12
2014/04/15 10:15:10 [debug] 21157#0: *1 content phase: 13
2014/04/15 10:15:10 [debug] 21157#0: *1 content phase: 14
2014/04/15 10:15:10 [debug] 21157#0: *1 content phase: 15
2014/04/15 10:15:10 [debug] 21157#0: *1 content phase: 16
2014/04/15 10:15:10 [debug] 21157#0: *1 content phase: 17
2014/04/15 10:15:10 [debug] 21157#0: *1 http filename: "$webroot/mxui/ui/mxui.css.gz"
2014/04/15 10:15:10 [debug] 21157#0: *1 add cleanup: 0000000001B51770
2014/04/15 10:15:10 [debug] 21157#0: *1 http static fd: 19
2014/04/15 10:15:10 [debug] 21157#0: *1 xslt filter header
2014/04/15 10:15:10 [debug] 21157#0: *1 spdy header filter
2014/04/15 10:15:10 [debug] 21157#0: *1 malloc: 0000000001A890A0:281
2014/04/15 10:15:10 [debug] 21157#0: *1 spdy deflate out: ni:0000000001A891AA no:0000000001B52336 ai:0 ao:38 rc:0
2014/04/15 10:15:10 [debug] 21157#0: *1 spdy:1 create SYN_REPLY frame 0000000001B51948: len:286
2014/04/15 10:15:10 [debug] 21157#0: *1 http cleanup add: 0000000001B51988
2014/04/15 10:15:10 [debug] 21157#0: *1 spdy frame out: 0000000001B51948 sid:1 prio:2 bl:1 len:286
2014/04/15 10:15:10 [debug] 21157#0: *1 malloc: 0000000001BAB210:16384
2014/04/15 10:15:10 [debug] 21157#0: *1 SSL buf copy: 294
2014/04/15 10:15:10 [debug] 21157#0: *1 spdy:1 SYN_REPLY frame 0000000001B51948 was sent
2014/04/15 10:15:10 [debug] 21157#0: *1 spdy frame sent: 0000000001B51948 sid:1 bl:1 len:286
2014/04/15 10:15:10 [debug] 21157#0: *1 http output filter "/mxui/ui/mxui.css?"
2014/04/15 10:15:10 [debug] 21157#0: *1 http copy filter: "/mxui/ui/mxui.css?"
2014/04/15 10:15:10 [debug] 21157#0: *1 malloc: 0000000001BAF220:17347
2014/04/15 10:15:10 [debug] 21157#0: *1 read: 19, 0000000001BAF220, 17347, 0
2014/04/15 10:15:10 [debug] 21157#0: *1 image filter
2014/04/15 10:15:10 [debug] 21157#0: *1 xslt filter body
2014/04/15 10:15:10 [debug] 21157#0: *1 http postpone filter "/mxui/ui/mxui.css?" 0000000001B523B0
2014/04/15 10:15:10 [debug] 21157#0: *1 write new buf t:1 f:1 0000000001BAF220, pos 0000000001BAF220, size: 17347 file: 0, size: 17347
2014/04/15 10:15:10 [debug] 21157#0: *1 http write filter: l:1 f:0 s:17347
2014/04/15 10:15:10 [debug] 21157#0: *1 http write filter limit 0
2014/04/15 10:15:10 [debug] 21157#0: *1 spdy:1 create DATA frame 0000000001B51948: len:8192 flags:0
2014/04/15 10:15:10 [debug] 21157#0: *1 spdy:1 create DATA frame 0000000001B524F0: len:8192 flags:0
2014/04/15 10:15:10 [debug] 21157#0: *1 spdy:1 create DATA frame 0000000001B525F8: len:963 flags:1
2014/04/15 10:15:10 [debug] 21157#0: *1 spdy frame out: 0000000001B525F8 sid:1 prio:2 bl:0 len:963
2014/04/15 10:15:10 [debug] 21157#0: *1 spdy frame out: 0000000001B524F0 sid:1 prio:2 bl:0 len:8192
2014/04/15 10:15:10 [debug] 21157#0: *1 spdy frame out: 0000000001B51948 sid:1 prio:2 bl:0 len:8192
2014/04/15 10:15:10 [debug] 21157#0: *1 SSL buf copy: 8
2014/04/15 10:15:10 [debug] 21157#0: *1 SSL buf copy: 8192
2014/04/15 10:15:10 [debug] 21157#0: *1 SSL buf copy: 8
2014/04/15 10:15:10 [debug] 21157#0: *1 SSL buf copy: 7882
2014/04/15 10:15:10 [debug] 21157#0: *1 SSL to write: 16384
2014/04/15 10:15:10 [debug] 21157#0: *1 SSL_write: 16384
2014/04/15 10:15:10 [debug] 21157#0: *1 SSL buf copy: 310
2014/04/15 10:15:10 [debug] 21157#0: *1 SSL buf copy: 8
2014/04/15 10:15:10 [debug] 21157#0: *1 SSL buf copy: 963
2014/04/15 10:15:10 [debug] 21157#0: *1 SSL to write: 1281
2014/04/15 10:15:10 [debug] 21157#0: *1 SSL_write: 1281
2014/04/15 10:15:10 [debug] 21157#0: *1 spdy:1 DATA frame 0000000001B51948 was sent
2014/04/15 10:15:10 [debug] 21157#0: *1 spdy frame sent: 0000000001B51948 sid:1 bl:0 len:8192
2014/04/15 10:15:10 [debug] 21157#0: *1 spdy:1 DATA frame 0000000001B524F0 was sent
2014/04/15 10:15:10 [debug] 21157#0: *1 spdy frame sent: 0000000001B524F0 sid:1 bl:0 len:8192
2014/04/15 10:15:10 [debug] 21157#0: *1 spdy:1 DATA frame 0000000001B525F8 was sent
2014/04/15 10:15:10 [debug] 21157#0: *1 spdy frame sent: 0000000001B525F8 sid:1 bl:0 len:963
2014/04/15 10:15:10 [debug] 21157#0: *1 http write filter 0000000000000000
2014/04/15 10:15:10 [debug] 21157#0: *1 http copy filter: 0 "/mxui/ui/mxui.css?"
2014/04/15 10:15:10 [debug] 21157#0: *1 http finalize request: 0, "/mxui/ui/mxui.css?" a:1, c:1
2014/04/15 10:15:10 [debug] 21157#0: *1 http request count:1 blk:0
2014/04/15 10:15:10 [debug] 21157#0: *1 spdy close stream 1, queued 0, processing 1
2014/04/15 10:15:10 [debug] 21157#0: *1 http close request
2014/04/15 10:15:10 [debug] 21157#0: *1 http log handler
2014/04/15 10:15:10 [debug] 21157#0: *1 run cleanup: 0000000001B51770
2014/04/15 10:15:10 [debug] 21157#0: *1 file cleanup: fd:19
2014/04/15 10:15:10 [debug] 21157#0: *1 free: 0000000001BAF220
2014/04/15 10:15:10 [debug] 21157#0: *1 free: 0000000001B50A20, unused: 0
2014/04/15 10:15:10 [debug] 21157#0: *1 free: 0000000001B51A30, unused: 580
2014/04/15 10:15:10 [debug] 21157#0: *1 spdy process frame head:80030009 f:0 l:8
2014/04/15 10:15:10 [debug] 21157#0: *1 spdy WINDOW_UPDATE sid:1 delta:268369920
2014/04/15 10:15:10 [info] 21157#0: *1 client sent WINDOW_UPDATE frame for unknown stream 1 while processing SPDY, client: $remote_addr, server: 0.0.0.0:443
2014/04/15 10:15:10 [debug] 21157#0: *1 spdy write RST_STREAM sid:1 st:2
2014/04/15 10:15:10 [debug] 21157#0: *1 spdy frame out: 0000000001B4FD58 sid:0 prio:7 bl:0 len:8
2014/04/15 10:15:10 [debug] 21157#0: *1 SSL buf copy: 16
2014/04/15 10:15:10 [debug] 21157#0: *1 SSL to write: 16
2014/04/15 10:15:10 [debug] 21157#0: *1 SSL_write: 16
2014/04/15 10:15:10 [debug] 21157#0: *1 spdy frame sent: 0000000001B4FD58 sid:0 bl:0 len:8
2014/04/15 10:15:10 [debug] 21157#0: *1 free: 0000000001B4FA10, unused: 3080
2014/04/15 10:15:10 [debug] 21157#0: *1 free: 0000000001BAB210
2014/04/15 10:15:10 [debug] 21157#0: *1 reusable connection: 1
2014/04/15 10:15:10 [debug] 21157#0: *1 event timer: 18, old: 1397549890262, new: 1397549890266

comment:3 by frankbb.pip.verisignlabs.com, 10 years ago

Resolution: invalid
Status: closedreopened

in reply to:  2 comment:4 by Valentin V. Bartenev, 10 years ago

Replying to frankbb.pip.verisignlabs.com:

But if that is the case why would NGINX serve mxui.css.gz and not mxui.css in case 3?

Because nginx knows that if a client uses SPDY then it supports gzip compression anyway (this is mandatory by SPDY specification).

Your second nginx receives requests over HTTP and therefore the header is required.

comment:5 by frankbb.pip.verisignlabs.com, 10 years ago

Sounds fair, i added a ticket at Firefox, this ticket can be closed.

comment:6 by Valentin V. Bartenev, 10 years ago

Resolution: fixed
Status: reopenedclosed
Version 0, edited 10 years ago by Valentin V. Bartenev (next)
Note: See TracTickets for help on using tickets.