I use Rails3 with Nginx.
I serve files through controller:uploads action.
class BannersController < ApplicationController
... # authentication
def uploads
send_file '{localFilePath}', :disposition => 'inline'
end
end
I uncomment this line
config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
in environments/production.rb.
I also defined a mime type 'm4v' inside my initializers/mime_types.rb
Mime::Type.register "video/mp4", :m4v
MIME::Types.add(MIME::Type.from_array("video/mp4", %(m4v)))
My nginx configuration looks like this
http {
... # ruby-1.9.3-p0
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
server {
client_max_body_size 30M;
listen 80;
server_name ...
root ...
passenger_enabled on;
rails_env production;
location ~ ^/(assets)/ {
root ...
gzip_static on;
expires max;
add_header Cache-Control public;
}
}
}
When I request a video file http://{ip}/components/{id}/content/host_bg.m4v file I see errors in my chrome console (single request produces 4 lines)
How can I fix that? I guess my nginx configuration is not complete. Note that I can play video but it is not served as expected (e.g. javascript HTML5 jPlayer can play the video only once then it stops, the repeat works from other http locations). Thanks!