<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"><channel><title>Homo-Adminus Blog - Latest Comments in Using X-Accel-Redirect Header With Nginx to Implement Controlled Downloads (with rails and php examples)</title><link>http://homo-adminus.disqus.com/</link><description></description><language>en</language><lastBuildDate>Mon, 16 Jun 2008 15:40:08 -0000</lastBuildDate><item><title>Re: Using X-Accel-Redirect Header With Nginx to Implement Controlled Downloads (with rails and php examples)</title><link>http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/#comment-2460693</link><description>Кстати, есть такая функция в php&lt;br&gt;string mime_content_type ( string filename)&lt;br&gt;не тестировал, но если работает - удобно</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">А. Александров</dc:creator><pubDate>Mon, 16 Jun 2008 15:40:08 -0000</pubDate></item><item><title>Re: Using X-Accel-Redirect Header With Nginx to Implement Controlled Downloads (with rails and php examples)</title><link>http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/#comment-2460692</link><description>Чтобы правильно отдавать тип и имя файла:&lt;br&gt;&amp;lt;?php      &lt;br&gt;header("Content-type: video/mpeg");&lt;br&gt;header("Content-Disposition: attachment; filename=\"file.mpeg\"");&lt;br&gt;//или подставить свой&lt;br&gt;Чтобы не задалбывали потоками reget, dmaster etc..&lt;br&gt;в nginx.conf&lt;br&gt;http {&lt;br&gt;    limit_zone   one  $binary_remote_addr  10m;&lt;br&gt;...&lt;br&gt;		location /files {&lt;br&gt;			root /home/www/.../files;&lt;br&gt;			internal;&lt;br&gt;			limit_conn   one  1;&lt;br&gt;		}&lt;br&gt;где one-имя зоны, 1-количество подкл. с одного ip</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">А. Александров</dc:creator><pubDate>Mon, 16 Jun 2008 15:35:45 -0000</pubDate></item><item><title>Re: Using X-Accel-Redirect Header With Nginx to Implement Controlled Downloads (with rails and php examples)</title><link>http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/#comment-2460694</link><description>Спасибо за статью.&lt;br&gt;&lt;br&gt;С заголовками таки что-то не то - FF и IE отрабатывают нормально, а вот Опера упорно предлагает сохранить в html ...</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Stas</dc:creator><pubDate>Thu, 24 Apr 2008 07:58:40 -0000</pubDate></item><item><title>Re: Using X-Accel-Redirect Header With Nginx to Implement Controlled Downloads (with rails and php examples)</title><link>http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/#comment-2460691</link><description>Про использование в lighttpd контролируемых скачек с помощью скриптов можно поподробнее?</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">алексей</dc:creator><pubDate>Thu, 10 Apr 2008 05:02:27 -0000</pubDate></item><item><title>Re: Using X-Accel-Redirect Header With Nginx to Implement Controlled Downloads (with rails and php examples)</title><link>http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/#comment-2460687</link><description>&amp;gt;What about the rest of the code for the rails controller.&lt;br&gt;&amp;gt;This confuses me because you have to render something….?&lt;br&gt;&amp;gt;I have nginx setup and I am setting the header, but then what? &amp;gt;render :text =&amp;gt; “”???&lt;br&gt;&lt;br&gt;render :nothing =&amp;gt; true</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Morales</dc:creator><pubDate>Fri, 25 Jan 2008 10:40:01 -0000</pubDate></item><item><title>Re: Using X-Accel-Redirect Header With Nginx to Implement Controlled Downloads (with rails and php examples)</title><link>http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/#comment-2460690</link><description>При попытке использовать описанную схему контролируемого скачивания (nginx+apache+php) столкнулся со след. проблемой: иногда вместо предложения сохранить файл в браузер выдается ошибка :&lt;br&gt;502 Bad Gateway&lt;br&gt;nginx/0.5.33&lt;br&gt;При этом в PHP скрипт передается $path с запорченным окончанием - последние несколько символов заменены на 0x0. В error.log nginx'а при этом выдается сообщение:&lt;br&gt;upstream prematurely closed connection while reading response header from&lt;br&gt;upstream ...&lt;br&gt;Как с этим бороться?</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Vladimir</dc:creator><pubDate>Mon, 21 Jan 2008 04:44:53 -0000</pubDate></item><item><title>Re: Using X-Accel-Redirect Header With Nginx to Implement Controlled Downloads (with rails and php examples)</title><link>http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/#comment-2460688</link><description>в тему предыдущего коммента - вопрос закрыт. проблема была в размере файла - больше 4 гб. Интернет експлорер побоялся что на машине фат32 и не стал качать.</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ivan</dc:creator><pubDate>Tue, 15 Jan 2008 09:37:49 -0000</pubDate></item><item><title>Re: Using X-Accel-Redirect Header With Nginx to Implement Controlled Downloads (with rails and php examples)</title><link>http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/#comment-2460689</link><description>Добрый день. А никто не сталкивался со следующей ситуацией: есть файл который отдается через X-Accel-Redirect. При попытке его скачать с двух различных машин - качается только на одной. Проблема имеет место только при скачивании через браузер (тестировался ie6-7 и ff2), выдается невозможность отобразить страницу. При использовании менеджера закачек - все качается нормально.</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ivan</dc:creator><pubDate>Tue, 15 Jan 2008 06:20:06 -0000</pubDate></item><item><title>Re: Using X-Accel-Redirect Header With Nginx to Implement Controlled Downloads (with rails and php examples)</title><link>http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/#comment-2460686</link><description>перед X-Accel-Redirect вставьте:&lt;br&gt;&lt;br&gt;header("Content-Disposition: attachment; filename=\"" . $filename . "\"");&lt;br&gt;&lt;br&gt;где $filename - имя файла (только имя, путь - отсутствует). &lt;br&gt;После этого все браузеры должны открывать окно с приглашением сохранить файл или открыть. Ну у MIME типы уже сам nginx отдаст если в его конфиге добавлено include conf/mime.types</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Goga</dc:creator><pubDate>Wed, 26 Dec 2007 04:37:36 -0000</pubDate></item><item><title>Re: Using X-Accel-Redirect Header With Nginx to Implement Controlled Downloads (with rails and php examples)</title><link>http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/#comment-2460685</link><description>При таком подходе в заголовке Content-Type всегда оказывается text/html. Соответственно, бинарный файл загружается браузером в окно а не предлагается для скачивания. &lt;br&gt;&lt;br&gt;Как оказалось, это заголовок по умолчанию, который выдает сам PHP скрипт, и nginx его уже не трогает. &lt;br&gt;&lt;br&gt;Выход довольно прост, надо запретить PHP выдавать этот заголовок, например, так:&lt;br&gt;&lt;br&gt;ini_set('default_mimetype', '');&lt;br&gt;&lt;br&gt;Если кто подскажет, как это сделать более элегантно - буду благодарен.</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">jsmirnoff</dc:creator><pubDate>Sat, 24 Nov 2007 16:28:21 -0000</pubDate></item><item><title>Re: Using X-Accel-Redirect Header With Nginx to Implement Controlled Downloads (with rails and php examples)</title><link>http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/#comment-2460684</link><description>This works great for me. I modified the x_send_file rails plugin to work with nginx.&lt;br&gt;&lt;a href="http://spongetech.wordpress.com/2007/11/13/the-complete-nginx-solution-to-sending-flowers-and-files-with-rails/" rel="nofollow"&gt;http://spongetech.wordpress.com/2007/11/13/the-...&lt;/a&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Blythe</dc:creator><pubDate>Tue, 13 Nov 2007 17:31:04 -0000</pubDate></item><item><title>Re: Using X-Accel-Redirect Header With Nginx to Implement Controlled Downloads (with rails and php examples)</title><link>http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/#comment-2460683</link><description>a sto  tut  delat???</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">erik</dc:creator><pubDate>Fri, 09 Nov 2007 13:54:06 -0000</pubDate></item><item><title>Re: Using X-Accel-Redirect Header With Nginx to Implement Controlled Downloads (with rails and php examples)</title><link>http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/#comment-2460682</link><description>For explorer 6 users downloading pdfs you also need to set the cache-control header, or you get a 'document not found' error message from the acrobat reader. It seems this is because the explorer regards the file as temporary and deletes it before acrobat can see it. &lt;br&gt;&lt;br&gt;anyway, i use this to make pdf downloads work:&lt;br&gt;&lt;br&gt;&lt;code&gt;&lt;br&gt;   location /download_control/ {&lt;br&gt;       root ...;&lt;br&gt;       default_type  application/pdf;&lt;br&gt;       expires 1h;&lt;br&gt;       add_header  Cache-Control  private;&lt;br&gt;       internal;&lt;br&gt;   }&lt;br&gt;&lt;/code&gt;&lt;br&gt;&lt;br&gt;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.</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">WIll</dc:creator><pubDate>Fri, 09 Nov 2007 05:59:40 -0000</pubDate></item><item><title>Re: Using X-Accel-Redirect Header With Nginx to Implement Controlled Downloads (with rails and php examples)</title><link>http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/#comment-2460681</link><description>What about the rest of the code for the rails controller.&lt;br&gt;&lt;br&gt;This confuses me because you have to render something....?&lt;br&gt;&lt;br&gt;I have nginx setup and I am setting the header, but then what? render :text =&amp;gt; ""???</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Alex Egg</dc:creator><pubDate>Thu, 08 Nov 2007 02:51:21 -0000</pubDate></item><item><title>Re: Using X-Accel-Redirect Header With Nginx to Implement Controlled Downloads (with rails and php examples)</title><link>http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/#comment-2460680</link><description>Ошибочка маленькая в rewrite, должно быть так, видимо:&lt;br&gt;rewrite ^/download/(.*)$ /down.php?path=$1 last;&lt;br&gt;&lt;br&gt;2 Andrey Popov:&lt;br&gt;Попробуй перед редиректом (X-Accel-Redirect) отдавать заголовок руками т.е.:&lt;br&gt;Content-type: application/octet-stream</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">square</dc:creator><pubDate>Mon, 29 Oct 2007 23:43:05 -0000</pubDate></item><item><title>Re: Using X-Accel-Redirect Header With Nginx to Implement Controlled Downloads (with rails and php examples)</title><link>http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/#comment-2460679</link><description>2si-rus: он реализуется родными средствами (if + regexp) в конфиге.</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Scoundrel</dc:creator><pubDate>Wed, 18 Jul 2007 16:22:52 -0000</pubDate></item><item><title>Re: Using X-Accel-Redirect Header With Nginx to Implement Controlled Downloads (with rails and php examples)</title><link>http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/#comment-2460677</link><description>Как вы смотрите на то, чтобы для уменьшения нагрузки дописать к nginx модуль или фильтр какой нить для реализации антилича.</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">si-rus</dc:creator><pubDate>Sun, 15 Jul 2007 16:30:48 -0000</pubDate></item><item><title>Re: Using X-Accel-Redirect Header With Nginx to Implement Controlled Downloads (with rails and php examples)</title><link>http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/#comment-2460678</link><description>нет, это статья не все. если использовать пхп как модуль апача, то сервер ляжет под нагрузкой, когда обратятся несколько юзверов при помощи флашгета с 10 потоками. Лучшим вариантом будет запуск проверяющего скрипта на фастCGI.</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">znikus</dc:creator><pubDate>Fri, 13 Jul 2007 08:51:22 -0000</pubDate></item><item><title>Re: Using X-Accel-Redirect Header With Nginx to Implement Controlled Downloads (with rails and php examples)</title><link>http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/#comment-2460676</link><description>DOES NGINX IPV6 CAPABLE ???????!!!!!!!!!!!!!??????????????????!!!!!!!!!!!!!???????????????????!!!!!!!!!!!!!!!!!!!!</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">jackaXs</dc:creator><pubDate>Sat, 07 Jul 2007 19:34:12 -0000</pubDate></item><item><title>Re: Using X-Accel-Redirect Header With Nginx to Implement Controlled Downloads (with rails and php examples)</title><link>http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/#comment-2460675</link><description>&amp;gt; Можно по подробнее, из-за чего nginx выдает на .exe файлы, text/html вместо application/octet-stream?&lt;br&gt;Это может быть потому, что процесс выдает ошибку "500 No template for action download"&lt;br&gt;так как ошибка выводится в html, то она подменяет заголовок на text/html.&lt;br&gt;проверьте логи ruby</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">nir0</dc:creator><pubDate>Tue, 26 Jun 2007 12:21:27 -0000</pubDate></item><item><title>Re: Using X-Accel-Redirect Header With Nginx to Implement Controlled Downloads (with rails and php examples)</title><link>http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/#comment-2460674</link><description>Можно по подробнее, из-за чего nginx выдает на  .exe файлы, text/html вместо application/octet-stream?</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Andrey Popov</dc:creator><pubDate>Wed, 20 Jun 2007 11:35:28 -0000</pubDate></item><item><title>Re: Using X-Accel-Redirect Header With Nginx to Implement Controlled Downloads (with rails and php examples)</title><link>http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/#comment-2460673</link><description>2pereksid: Можно и такое. Называлось вроде post_action - нгинкс умеет дергать нужный урл когда юзер все докачает.</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Scoundrel</dc:creator><pubDate>Wed, 16 May 2007 14:18:40 -0000</pubDate></item><item><title>Re: Using X-Accel-Redirect Header With Nginx to Implement Controlled Downloads (with rails and php examples)</title><link>http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/#comment-2460672</link><description>Здорово. Часто под контролируемым скачиванием понимают еще и отметку, когда скачивание файла было закончено. Тут nginx помочь может?</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">peroksid</dc:creator><pubDate>Wed, 16 May 2007 12:35:56 -0000</pubDate></item><item><title>Re: Using X-Accel-Redirect Header With Nginx to Implement Controlled Downloads (with rails and php examples)</title><link>http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/#comment-2460671</link><description>Неужели и не решили проблеммы с сменой заголовка ??</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ruby</dc:creator><pubDate>Mon, 23 Apr 2007 04:34:20 -0000</pubDate></item><item><title>Re: Using X-Accel-Redirect Header With Nginx to Implement Controlled Downloads (with rails and php examples)</title><link>http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/#comment-2460670</link><description>good article.&lt;br&gt;I have thanslated it into Simplified-Chinese:&lt;br&gt;&lt;a href="http://bianbian.sunshow.net/index.php/technology/154.html" rel="nofollow"&gt;http://bianbian.sunshow.net/index.php/technolog...&lt;/a&gt;&lt;br&gt;enjoy~</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">bianbian</dc:creator><pubDate>Thu, 05 Apr 2007 05:11:47 -0000</pubDate></item></channel></rss>