Nginx is not accepting range of bytes

自作多情 提交于 2020-01-22 20:08:06

问题


I am using nginx to serve videos from the file system. I would like to enable range request.

Currently this is the result returned for my file

curl -I fileurl
HTTP/1.1 200 OK
Server: nginx
Date: Sat, 29 Mar 2014 06:41:41 GMT
Content-Type: video/mp4
Content-Length: 15603963
Last-Modified: Sat, 04 Jan 2014 15:02:26 GMT
Connection: keep-alive
Keep-Alive: timeout=300
Accept-Ranges: bytes

But if I send curl --header "Range: bytes=0-50" fileurl

the whole file is downloaded.

This is the server in nginx config:

server {
            listen 80;
            server_name myserver;
            error_log logs/myserver.error.log;
            access_log logs/myserver.access.log;

            root /srv/myserver;

            #add_header Accept-Ranges;
            add_header Accept-Ranges bytes;
    }

Do I have to enable anything else? How could I allow range requests for the files?


回答1:


I was able to get range requests working after adding the following line to my nginx site config

    proxy_force_ranges on;

You can read more about it here




回答2:


I have found it - its the option

max_ranges

It was max_ranges 0 at the bottom of the configuration.




回答3:


The content type for .m4v files is video/x-m4v, I don't think video/mp4 will work for those.



来源:https://stackoverflow.com/questions/22728016/nginx-is-not-accepting-range-of-bytes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!