What can i do if i need to send file which is not on current server and i don't want to waste the time of client for downloading on my server?
I can't use proxy_pass to file server because i need to save this file on the main server to prevent re-downloading again and again in case this file is very popular - it will cost a lot.
I'm using download.php and X-Accel-Redirect. I tried to set the real Content-Length of file - it did't help, nginx ignore content-length header from my php script, it gives actual size of downloading file.
I tried chunked_transfer_encoding on; + header('Transfer-Encoding: chunked'); didn't help - the same situation
So in other words,
Client requests file 'test.mp4' from 'server_1' 'server_1' downloads a file from 'server_2' using http streaming. So i can stream from 'server_2' but i don't need. I need send this file to the client while it's downloading...