Problem with accelerated Rails downloads with NGINX using X-Accel-Redirect header

Added by Djordjije Crni over 3 years ago

Rails has an option to use X-Accel-Redirect. See more info:

https://mattbrictson.com/accelerated-rails-downloads
http://thedataasylum.com/articles/how-rails-nginx-x-accel-redirect-work-together.html

When properly configured, file downloads will be served by Nginx directly.
There is one problem: if Redmine has been configured with mandatory authentication (without anonymous access), then it is necessary that user have to be logged in, in order to successfully download file from Redmine. If user is not logged in, file download will fail, and web browser be rerouted to incorrect login back_url, containing Nginx upstream URL.

How to avoid this problem?