<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Apr 13, 2013, at 10:45 PM, Роман <<a href="mailto:n.g.i.n.x.e.r@gmail.com">n.g.i.n.x.e.r@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Есть задачка скрыть реальное нахождение файла и отдавать его по<br>короткой ссылке. Например: заходим по ссылке<br><a href="http://site.com/03209393/file.tgz">http://site.com/03209393/file.tgz</a>, скачивание идет по ссылке<br><a href="http://site.com/03209393/file.tgz">http://site.com/03209393/file.tgz</a>, а на самом деле файл находится тут<br><a href="http://site.com/arhive/file.tgz">http://site.com/arhive/file.tgz</a><br><br>Задача довольно простая на первый взгляд, если бы не одно но.<br><br>Можно ли читать реальную ссылку не скриптом, а например из мемкеша?<br>Тогда бы nginx считывал ссылку и от давал файл без какого либо скрипта<br>в бекенде.<br><br>Вся задача сводится к убиранию бекенда.<br></blockquote><div><br></div><div>можно даже без мемкэша обойтись, просто соберите nginx с опцией <span style="background-color: rgb(255, 255, 255); font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; line-height: 16px; white-space: pre; ">--with-http_secure_link_module</span></div><div><br></div><div><pre class="line-pre" style="font-size: 12px; line-height: 16px; font-family: Consolas, 'Liberation Mono', Courier, monospace; word-wrap: break-word; width: 744px; margin-top: 0px; margin-bottom: 0px; padding: 0px; background-color: rgb(255, 255, 255); position: static; z-index: auto; "><div class="line" id="file-2-nginx-conf-LC37">        location /download/ {</div><div class="line" id="file-2-nginx-conf-LC38">          rewrite         /download/([a-zA-Z0-9_\-]*)/([0-9]*)/(.*)\.tgz$ /archive/$3.tgz?st=$1&e=$2;</div><div class="line" id="file-2-nginx-conf-LC39">        }</div></pre><div><br></div><div><pre class="line-pre" style="font-size: 12px; line-height: 16px; font-family: Consolas, 'Liberation Mono', Courier, monospace; word-wrap: break-word; width: 744px; margin-top: 0px; margin-bottom: 0px; padding: 0px; background-color: rgb(255, 255, 255); position: static; z-index: auto; "><div class="line" id="file-2-nginx-conf-LC41">        location /archive/ {</div><div class="line" id="file-2-nginx-conf-LC42">          internal;</div><div class="line" id="file-2-nginx-conf-LC43">          secure_link           $arg_st,$arg_e;</div><div class="line" id="file-2-nginx-conf-LC44">          secure_link_md5       YOUR_SECRET_PASSWORD_HERE$arg_e$uri;</div><div class="line" id="file-2-nginx-conf-LC45"> </div><div class="line" id="file-2-nginx-conf-LC46">          if ($secure_link = "")  { return 403; }</div><div class="line" id="file-2-nginx-conf-LC47">          if ($secure_link = "0") { return 403; }</div><div class="line" id="file-2-nginx-conf-LC48"> </div></pre><div>             }</div></div><div><br></div></div><div><span style="font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; line-height: 16px; white-space: pre; background-color: rgb(255, 255, 255); ">YOUR_SECRET_PASSWORD_HERE - </span>пароль, с помощью которого вы делаете шифр, $arg_e - timestamp</div><div>пример того, как генерить урлы на Ruby здесь <a href="https://gist.github.com/mikhailov/3174601">https://gist.github.com/mikhailov/3174601</a></div><div><br></div><blockquote type="cite">_______________________________________________<br>nginx-ru mailing list<br><a href="mailto:nginx-ru@nginx.org">nginx-ru@nginx.org</a><br>http://mailman.nginx.org/mailman/listinfo/nginx-ru</blockquote></div><br></body></html>