Downloading uploaded zip files: net::ERR_INVALID_RESPONSE

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

Result: Failed to load resource: net::ERR_INVALID_RESPONSE. Grey page.

Production log.

Started GET "/uploads/default/2842/" for 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/ (0.1ms)
Completed 200 OK in 57ms (ActiveRecord: 17.4ms)
Started GET "/home/discourse/www/discourse/releases/20150513094508/public/uploads/default/2842/" for$

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.

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 – I was able to upload a zip and download it, no problem.

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";