# Downloading uploaded zip files: net::ERR\_INVALID\_RESPONSE

**URL:** https://meta.discourse.org/t/downloading-uploaded-zip-files-net-err-invalid-response/28758
**Category:** Self-hosting
**Created:** [13 مايو 2015، 10:16ص UTC](https://meta.discourse.org/t/downloading-uploaded-zip-files-net-err-invalid-response/28758 "2015-05-13T10:16:06Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![masda70](https://avatars.discourse-cdn.com/v4/letter/m/94ad74/32.png) [@masda70](https://meta.discourse.org/u/masda70)
#### Post date: [13 مايو 2015، 10:16ص UTC](https://meta.discourse.org/t/downloading-uploaded-zip-files-net-err-invalid-response/28758/1 "2015-05-13T10:16:06Z")

</div>

**Setup:** Unicorn behind Nginx installation with SSL. Latest Discourse (master). .zip uploads are allowed.  
**Operation:** download an uploaded .zip file.

Attempting GET request from authenticated user in Chrome at [https://example.com/uploads/default/2842/e77595f6cc30a53c.zip](https://example.com/uploads/default/2842/e77595f6cc30a53c.zip)

**Result:** Failed to load resource: net::ERR\_INVALID\_RESPONSE. Grey page.

Production log.

```plaintext
Started GET "/uploads/default/2842/e77595f6cc30a53c.zip" for 109.0.230.82 at 2015-05-13 12:04:21 +0200
Processing by UploadsController#show as HTML
  Parameters: {"site"=>"default", "id"=>"2842", "sha"=>"e77595f6cc30a53c", "extension"=>"zip"}
Sent file /home/discourse/www/discourse/releases/20150513094508/public/uploads/default/2842/e77595f6cc30a53c.zip (0.1ms)
Completed 200 OK in 57ms (ActiveRecord: 17.4ms)
Started GET "/home/discourse/www/discourse/releases/20150513094508/public/uploads/default/2842/e77595f6cc30a53c.zip" for 109.0.230.82$

ActionController::RoutingError (No route matches [GET] "/home/discourse/www/discourse/releases/20150513094508/public/uploads/default/$
  config/initializers/quiet_logger.rb:10:in `call_with_quiet_assets'
  config/initializers/silence_logger.rb:26:in `call'
  lib/middleware/request_tracker.rb:70:in `call'
  lib/scheduler/defer.rb:85:in `process_client'
  lib/middleware/unicorn_oobgc.rb:80:in `process_client'

Processing by ExceptionsController#not_found as HTML
  Rendered exceptions/not_found.html.erb within layouts/no_ember (13.8ms)
  Rendered layouts/_head.html.erb (0.1ms)
  Rendered common/_special_font_face.html.erb (0.4ms)
  Rendered common/_discourse_stylesheet.html.erb (0.3ms)
  Rendered application/_header.html.erb (0.1ms)
  Rendered text template (0.0ms)
Completed 404 Not Found in 23ms (Views: 1.6ms | ActiveRecord: 5.2ms)

```

I do not yet understand what is triggering the second request, and why the operation fails even though the first request returns a HTTP 200.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [13 مايو 2015، 10:31م UTC](https://meta.discourse.org/t/downloading-uploaded-zip-files-net-err-invalid-response/28758/2 "2015-05-13T22:31:34Z")

</div>

Are you on our official Docker install?

I can’t repro any problem with .zip files at all (once allowed) on my docker-based install at [discourse.codinghorror.com](http://discourse.codinghorror.com) – I was able to upload a zip and download it, no problem.

---

<div class="post-metadata">

### Author: ![masda70](https://avatars.discourse-cdn.com/v4/letter/m/94ad74/32.png) [@masda70](https://meta.discourse.org/u/masda70)
#### Post date: [14 مايو 2015، 8:21ص UTC](https://meta.discourse.org/t/downloading-uploaded-zip-files-net-err-invalid-response/28758/3 "2015-05-14T08:21:36Z")

</div>

Thanks, with that in mind, I managed to pinpoint my issue and fix it.  
Fact is, I’m not the official Docker install, for technical reasons, but I have copied much of its setup. I manually keep the config up to date.

I leave my solution for future reference:

My problem has to do with the configuration of Nginx’s X-Accel-Redirect. By default it’s based on the value of `$public`:  
`proxy_set_header X-Accel-Mapping $public/=/downloads/;`

In my particular setup, `$public` variable is set to:  
`set $public /home/discourse/www/discourse/current/public;`  
In my case, `/home/discourse/www/discourse/current` is actually a symbolic link to the current release directory,

So instead, I changed the mapping to:  
`proxy_set_header X-Accel-Mapping $public_pattern/=/downloads/;`

where `$public_pattern` is a regular expression to possible hard link values of my public directory.  
`set $public_pattern "/home/discourse/www/discourse/releases/\d{14}/public";`

Source:  
[http://airbladesoftware.com/notes/rails-nginx-x-accel-mapping/](http://airbladesoftware.com/notes/rails-nginx-x-accel-mapping/)

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [14 مايو 2015، 8:07م UTC](https://meta.discourse.org/t/downloading-uploaded-zip-files-net-err-invalid-response/28758/4 "2015-05-14T20:07:38Z")

</div>


