Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nginx is not accepting range of bytes

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?

like image 441
kmitov Avatar asked Mar 29 '14 06:03

kmitov


People also ask

What is nginx proxy buffer?

Proxy buffering means that NGINX stores the response from a server in internal buffers as it comes in, and doesn't start sending data to the client until the entire response is buffered.

What is range caching?

The Range Cache stores a set of ranges (on the order of 128 ranges, each having a start and end address), each of which has an associated metadata (which in our prototype is 32-bits).

Where is Nginx config file located?

Every NGINX configuration file will be found in the /etc/nginx/ directory, with the main configuration file located in /etc/nginx/nginx. conf . NGINX configuration options are known as “directives”: these are arranged into groups, known interchangeably as blocks or contexts .

What is upstream server in nginx?

The servers that Nginx proxies requests to are known as upstream servers. Nginx can proxy requests to servers that communicate using the http(s), FastCGI, SCGI, and uwsgi, or memcached protocols through separate sets of directives for each type of proxy.


1 Answers

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

like image 158
kn04 Avatar answered Sep 21 '22 14:09

kn04