Welcome! Log In Create A New Profile

Advanced

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

Posted by semtrox 
X-Accel-Redirection dont work by downloading a remote file
January 02, 2013 11:33AM
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!
Re: X-Accel-Redirection dont work by downloading a remote file
January 02, 2013 04:55PM
Has Nobody a Solution for me? :-(
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 176
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready