# Nginx 1.4.1 + 'gzip on' causes download of file instead of displaying it in browser

**URL:** <https://www.ruby-forum.com/t/nginx-1-4-1-gzip-on-causes-download-of-file-instead-of-displaying-it-in-browser/235040>\
**Category:** NGINX\
**Created:** [May 27, 2013, 9:45pm UTC](https://www.ruby-forum.com/t/nginx-1-4-1-gzip-on-causes-download-of-file-instead-of-displaying-it-in-browser/235040 "2013-05-27T21:45:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [May 27, 2013, 9:45pm UTC](https://www.ruby-forum.com/t/nginx-1-4-1-gzip-on-causes-download-of-file-instead-of-displaying-it-in-browser/235040/1 "2013-05-27T21:45:42Z")

</div>

when i use nginx 1.4.1 + ‘gzip on’, once in every 2 requests i get the  
index.php (which its output is text/html) being downloaded by the  
browser as  
unknown file type instead of displayed in it (the broswer displays the  
“download & save” window and writes in this window that its content type  
is  
‘application/octet-stream’)  
after i download it (firefox saves it with file extension ‘part’) - i  
see in  
the file the response header (200 OK etc.) + body chunked & still  
gzipped.  
when not using gzip - all works fine.  
when switching back to nginx 1.2.8 it never happens - with same  
configuration / site / request.  
i get to the site thru proxy module, using HTTP/1.1.

thanks in advance  
Gad

Posted at Nginx Forum:

> **[nginx 1.4.1 + 'gzip on' causes download of file instead of displaying it in...](https://forum.nginx.org/read.php?2,239608,239608#msg-239608)**
>
> when i use nginx 1.4.1 + 'gzip on', once in every 2 requests i get the index.php (which its output is text/html) being downloaded by the browser as unknown file type instead of displayed in it (the broswer displays the "download & save"...

---

<div class="post-metadata">

**Author:** ![gadh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/e19adc/32.png) [@gadh](https://www.ruby-forum.com/u/gadh)\
**Post date:** [May 28, 2013, 10:53am UTC](https://www.ruby-forum.com/t/nginx-1-4-1-gzip-on-causes-download-of-file-instead-of-displaying-it-in-browser/235040/2 "2013-05-28T10:53:01Z")

</div>

i found the bug - the web server returned in “Content-Type” header just  
“text/html” and not added “charset=UTF-8”.  
why text/html is not enough ?

Posted at Nginx Forum:

> **[Re: nginx 1.4.1 + 'gzip on' causes download of file instead of displaying it...](https://forum.nginx.org/read.php?2,239608,239622#msg-239622)**
>
> when i use nginx 1.4.1 + 'gzip on', once in every 2 requests i get the index.php (which its output is text/html) being downloaded by the browser as unknown file type instead of displayed in it (the broswer displays the "download & save"...

---

<div class="post-metadata">

**Author:** ![gadh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/e19adc/32.png) [@gadh](https://www.ruby-forum.com/u/gadh)\
**Post date:** [May 28, 2013, 12:34pm UTC](https://www.ruby-forum.com/t/nginx-1-4-1-gzip-on-causes-download-of-file-instead-of-displaying-it-in-browser/235040/3 "2013-05-28T12:34:06Z")

</div>

Hello!

On Tue, May 28, 2013 at 04:52:14AM -0400, gadh wrote:

> i found the bug - the web server returned in “Content-Type” header just  
> “text/html” and not added “charset=UTF-8”.  
> why text/html is not enough ?

For nginx, there should be no difference. But it looks like you  
are debugging complete system which includes backend software,  
nginx and a browser.

If you think that the problem is in nginx - first of all I would  
recommend you to look into debug log. See  
[A debugging log](http://nginx.org/en/docs/debugging_log.html) for details.

–  
Maxim D.

> **[nginx: donation](http://nginx.org/en/donation.html)**
