Community Page
- blog.kovyrin.net Jump to website »
-
Subscribe -
Community
-
Top Commenters
-
Popular Threads
-
Recent Comments
- nice article! nice site. you're in my rss feed now ;-) keep it up
- nice article! nice site. you're in my rss feed now ;-) keep it up
- nice article! nice site. you're in my rss feed now ;-) keep it up
- Top post. Thank you very much. :-)
- Thanks for the info. May God have mercy on us all.
Jump to original thread »
Using X-Accel-Redirect Header With Nginx to Implement Controlled Downloads (with rails and php examples)
Started by Scoundrel · 9 months ago
Sometimes you may need to implement controlled downloads when all downloads requests being sent to your script and then this script decides what to do: to send some file to the user or to show some access denied page or, maybe, do something else. In lighttpd server it can be done by returning
... Continue reading »
2 years ago
I have add it to the wiki site http://wiki.codemongers.com/NginxXSendfile
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
я реализовал контролируемые скачивания, но есть одна проблема - nginx со всеми файлами передает заголовок text/html, и браузер его соответственно открывает. не подскажете, с чем это может быть связано, и как испраить?
2 years ago
4to-bu zapretit - powli pustoj $r->send_http_header();
2 years ago
2 years ago
I have thanslated it into Simplified-Chinese:
http://bianbian.sunshow.net/index.php/technolog...
enjoy~
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
Это может быть потому, что процесс выдает ошибку "500 No template for action download"
так как ошибка выводится в html, то она подменяет заголовок на text/html.
проверьте логи ruby
2 years ago
1 year ago
1 year ago
1 year ago
1 year ago
rewrite ^/download/(.*)$ /down.php?path=$1 last;
2 Andrey Popov:
Попробуй перед редиректом (X-Accel-Redirect) отдавать заголовок руками т.е.:
Content-type: application/octet-stream
1 year ago
This confuses me because you have to render something....?
I have nginx setup and I am setting the header, but then what? render :text => ""???
1 year ago
anyway, i use this to make pdf downloads work:
location /download_control/ {
root ...;
default_type application/pdf;
expires 1h;
add_header Cache-Control private;
internal;
}
Otherwise, I've been very happy with nginx and this download control mechanism (and I've written a radiant plugin to make use of it, which should appear soon). thank you.
1 year ago
1 year ago
http://spongetech.wordpress.com/2007/11/13/the-...
1 year ago
Как оказалось, это заголовок по умолчанию, который выдает сам PHP скрипт, и nginx его уже не трогает.
Выход довольно прост, надо запретить PHP выдавать этот заголовок, например, так:
ini_set('default_mimetype', '');
Если кто подскажет, как это сделать более элегантно - буду благодарен.
1 year ago
header("Content-Disposition: attachment; filename=\"" . $filename . "\"");
где $filename - имя файла (только имя, путь - отсутствует).
После этого все браузеры должны открывать окно с приглашением сохранить файл или открыть. Ну у MIME типы уже сам nginx отдаст если в его конфиге добавлено include conf/mime.types
1 year ago
1 year ago
1 year ago
502 Bad Gateway
nginx/0.5.33
При этом в PHP скрипт передается $path с запорченным окончанием - последние несколько символов заменены на 0x0. В error.log nginx'а при этом выдается сообщение:
upstream prematurely closed connection while reading response header from
upstream ...
Как с этим бороться?
1 year ago
>This confuses me because you have to render something….?
>I have nginx setup and I am setting the header, but then what? >render :text => “”???
render :nothing => true
1 year ago
1 year ago
С заголовками таки что-то не то - FF и IE отрабатывают нормально, а вот Опера упорно предлагает сохранить в html ...
1 year ago
<?php
header("Content-type: video/mpeg");
header("Content-Disposition: attachment; filename=\"file.mpeg\"");
//или подставить свой
Чтобы не задалбывали потоками reget, dmaster etc..
в nginx.conf
http {
limit_zone one $binary_remote_addr 10m;
...
location /files {
root /home/www/.../files;
internal;
limit_conn one 1;
}
где one-имя зоны, 1-количество подкл. с одного ip
1 year ago
string mime_content_type ( string filename)
не тестировал, но если работает - удобно