ruby-on-rails – Capistrano和X-Sendfile
我正在尝试使用X-Sendfile工作来为capistrano提供重型附件.我发现X-Sendfile不能使用符号链接.我怎么能处理Capistrano符号链接的文件夹中的文件呢?
我的网络服务器是apache2乘客 在我的production.rb中: config.action_dispatch.x_sendfile_header = "X-Sendfile" 在我的控制器动作中: filename = File.join([Rails.root,"private/videos",@lesson.link_video1 + ".mp4"]) response.headers["X-Sendfile"]= filename send_file filename,:disposition => :inline,:stream => true,:x_sendfile => true render nothing: true 我的文件系统结构(其中“ – >”代表“symlink”,缩进意味着子文件夹): /var/www/myproject releases/ .... current/ -> /var/www/myproject/releases/xxxxxxxxxxxx app/ public/ private/ videos/ -> /home/ftp_user/videos 我的apache配置 我的应用程序能够提供小文件,但是对于大文件,它会产生NoMemoryError(无法分配内存) 我认为它不使用x-sendfile,因为如果我不使用它,行为是相同的. 以下是我正在尝试提供的文件的响应标头 Accept-Ranges:bytes Cache-Control:private Connection:Keep-Alive Content-Disposition:inline Content-Range:bytes 0-1265/980720989 Content-Transfer-Encoding:binary Content-Type:video/mp4 Date:Sat,01 Mar 2014 13:24:19 GMT ETag:"70b7da582d090774f6e42d4e44ae3ba5" Keep-Alive:timeout=5,max=97 Server:Apache/2.4.6 (Ubuntu) Status:200 OK Transfer-Encoding:chunked X-Content-Type-Options:nosniff X-Frame-Options:SAMEORIGIN X-Powered-By:Phusion Passenger 4.0.37 X-Request-Id:22ff0a30-c2fa-43fe-87c6-b9a5e7da12f2 X-Runtime:0.008150 X-UA-Compatible:chrome=1 X-XSS-Protection:1; mode=block 我真的不知道如何调试它,如果它是一个x-sendfile问题,或者我正在尝试为符号链接问题做一些不可能的事情 编辑: 我用这种方式创建了一个capistrano任务: task :storage_links do on roles(:web),in: :sequence,wait: 2 do #creo i link simbolici alle risorse within "/var/www/my_application/current/private" do execute :ln,"-nFs","/home/ftp_user/videos" end end end 我没有设法在finalize_update之后运行它,所以我在重启后手动运行它. 我用这种方式纠正了我的apache配置: XSendFilePath /var/www/my_application (在我将x-sendfile指向ftp文件夹之前) 在我的响应标题中,现在X-Sendfile也没有出现,我得到了206 – 部分内容,但一切似乎都有效,而apache正在以正确的方式提供文件(也是非常繁重的文件). 我知道这可能是一个安全问题,但我会尝试将它指向我的应用程序的最后一个版本,因为它指向当前的符号链接不起作用. 解决方法
也许我找到了解决方案.你是如何制作符号链接的?
也许你做了ln -s,但这还不够 Here他们建议使用ln -nFs,所以他认识到它是你要链接的目录 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |