I cannot download a zip file (using send_file
) when using nginx as a proxy.
def download
send_file file_path, filename: "file.zip"
end
Running without nginx (webrick only) it works fine but with the nginx proxy it opens this in the browser:
Nginx proxy config:
server {
server_name mydomain.com;
location / {
proxy_pass http://localhost:3001;
proxy_set_header Host $host;
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/keys/app.htpasswd;
}
}
Edit:
Reloading the page results in the document being downloaded, so I looked at the request headers for each request. They should both be the same, but they are not.
Opened in browser
Successfully downloaded
The only difference is that the first one I clicked a link (opening link in new tab downloads and opens the file) and I refreshed the page on the second one.
Edit 2:
I tried it again with webrick and it is doing the same thing.