# Nginx Gzip file download not working

**URL:** <https://www.ruby-forum.com/t/nginx-gzip-file-download-not-working/219714>\
**Category:** NGINX\
**Created:** [May 13, 2012, 10:19am UTC](https://www.ruby-forum.com/t/nginx-gzip-file-download-not-working/219714 "2012-05-13T10:19:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [May 13, 2012, 10:19am UTC](https://www.ruby-forum.com/t/nginx-gzip-file-download-not-working/219714/1 "2012-05-13T10:19:48Z")

</div>

Hi All,

When i try to download a file using “curl -H “Accept-Encoding: gzip”  
[http://abc.com/xx.epub](http://abc.com/xx.epub)” ,almost 99% file downloads and then it hangs and  
end up with this message “curl: (18) transfer closed with 2693 bytes  
remaining to read”. Please help.Do i need to change anything in server  
side to make this work?

this is my gzip configuration in nginx.conf

```
gzip on;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_proxied any;
gzip_min_length 1100;
gzip_buffers 16 8k;
gzip_disable "MSIE [1-6].(?!.*SV1)";
gzip_vary on;

```

Please help me…

Posted at Nginx Forum:

> **[nginx Gzip file download not working](https://forum.nginx.org/read.php?2,226362,226362#msg-226362)**
>
> Hi All, When i try to download a file using "curl -H "Accept-Encoding: gzip" http://abc.com/xx.epub" ,almost 99% file downloads and then it hangs and end up with this message "curl: (18) transfer closed with 2693 bytes...

---

<div class="post-metadata">

**Author:** ![pralive](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f475e1/32.png) [@pralive](https://www.ruby-forum.com/u/pralive)\
**Post date:** [May 14, 2012, 11:29pm UTC](https://www.ruby-forum.com/t/nginx-gzip-file-download-not-working/219714/2 "2012-05-14T23:29:09Z")

</div>

any help pls???

Posted at Nginx Forum:

> **[Re: nginx Gzip file download not working](https://forum.nginx.org/read.php?2,226362,226429#msg-226429)**
>
> Hi All, When i try to download a file using "curl -H "Accept-Encoding: gzip" http://abc.com/xx.epub" ,almost 99% file downloads and then it hangs and end up with this message "curl: (18) transfer closed with 2693 bytes...

---

<div class="post-metadata">

**Author:** ![pralive](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f475e1/32.png) [@pralive](https://www.ruby-forum.com/u/pralive)\
**Post date:** [May 15, 2012, 12:21am UTC](https://www.ruby-forum.com/t/nginx-gzip-file-download-not-working/219714/3 "2012-05-15T00:21:45Z")

</div>

On Sun, May 13, 2012 at 04:19:26AM -0400, pralive wrote:

Hi there,

> When i try to download a file using “curl -H “Accept-Encoding: gzip”  
> [http://abc.com/xx.epub](http://abc.com/xx.epub)” ,almost 99% file downloads and then it hangs and  
> end up with this message “curl: (18) transfer closed with 2693 bytes  
> remaining to read”.

Can you set up a test system, and find a minimum configuration that  
shows the problem you are seeing?

> Please help.Do i need to change anything in server  
> side to make this work?

The reason I ask, is: with this gzip-related configuration, and the rest  
being defaults, I don’t think that the gzip handler is involved here.

When I try the following test:

# nginx.conf:

events {  
worker\_connections 1024;  
debug\_connection 127.0.0.1;  
}

http {  
include mime.types;

```
gzip on;
gzip_min_length 1100;

server {
    listen 8000;
}

```

# }

# create my test file

perl -e ‘print “1234567890” x 111’ \> html/xx.epub

Then I can run the curl commands to get the file:

curl -I [http://localhost:8000/xx.epub](http://localhost:8000/xx.epub)  
curl -I -H ‘Accept-Encoding: gzip’ [http://localhost:8000/xx.epub](http://localhost:8000/xx.epub)

and they show the same response.

If I add the line

```
gzip_types text/plain;

```

to nginx.conf and reload, then the plain curl shows me

Content-Type: text/plain  
Content-Length: 1110

while the gzip one shows

Content-Type: text/plain  
Content-Encoding: gzip

So: I’m unable to replicate the problem you report; and it doesn’t  
immediately seem related to gzip.

Can you provide a replication recipe that someone else could run to see  
the same problem?

Do you see the problem with any other file? Or with the same file on a  
different server?

Also, the output of “nginx -V” and the logs, are likely to be useful.

Good luck with it,

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
