Quantcast
Channel: Nginx Forum
Viewing all articles
Browse latest Browse all 53287

X-Accel-Redirection dont work by downloading a remote file

$
0
0
hello everybody,

i want to download files via php an x-accel-redirect from a remote-server.
here is my php-file:

[code]
$fsize = remotefsize ( 'http://' . $filename );

$path_parts = pathinfo ( $filename );
$ext = strtolower ( $path_parts ["extension"] );

header ( "Content-Type: application/force-download" );
header ( "Content-Disposition: attachment; filename=\"" . $path_parts ["basename"] . "\"" );
header ( "Content-length: $fsize" );

header ( ' X-Accel-Redirect: /internal_redirect/' . $filename );
[/code]

and this is my nginx configuration

[code]
location ~* ^/internal_redirect/(.*?)/(.*) {
internal;

resolver 8.8.8.8;

set $download_uri $2;
set $download_host $1;

set $download_url http://$download_host/$download_uri;

proxy_set_header Host $download_host;
proxy_set_header Authorization '';

#proxy_hide_header Content-Disposition;
#add_header Content-Disposition 'attachment; filename="$args"';

proxy_max_temp_file_size 0;

proxy_pass $download_url;
}
[/code]

after i open the php-file in browser, the script is loading more than 30 seconds. after that the download-window will be shown. and if i download the file, the size will be 0 KB.

2 question:
- why is the script loading so long?
- why is the filesize 0 kb?

when i try to open the download-file directly in browser, everythings works fine...

thanks for your help!

Viewing all articles
Browse latest Browse all 53287

Trending Articles