difficulty adding headers

Maxim Dounin mdounin at mdounin.ru
Fri Jun 27 19:20:41 UTC 2014


On Fri, Jun 27, 2014 at 02:23:47PM -0400, ura wrote:

> this stackoverflow response on the topic is one that quotes the code i
> used... i have also seen this page linked by several other pages which said
> this was a workable approach:
> http://stackoverflow.com/questions/14598565/serving-206-byte-range-through-nginx-django

I think I understand the problem of the author of this question.  
I've added an answere there - most likely, it has ssi or something 
like enabled for all MIME types.

> i am not blindly following anything - i am looking at all the available
> information and referred to the nginx documentation - i am using what works
> and disregarding what does not. so far i have not found an explanation of
> this situation i am experiencing in the documentation or on forums, hence i
> am here asking.
> in any case, i removed return 206;
> the situation did not change.
> i am unclear why removing 'return 206' would cause a 200 response to become
> a 206 response! ;)

The 206 code indicates that "this was 200, but due to Range header 
only part of the actual response is returned".

> " If range requests are
> supported, the header will be added automatically."
> i am making a simple request for a static mp4 file via curl to nginx 1.7.2..
> i am not clear on your use of the idea of 'if range requests are supported'
> in this context. how would i know if they are supported or not?

If you don't see the Accept-Ranges header added to a response, then 
range requests are not supported.

If you don't see Accept-Ranges header added to responses to a 
static mp4 file, then there is something wrong in your config.  
Either a response is handled in a wrong location and ends up being 
handled not by nginx, or there is a filter active for some/all 
responses which may modify them and hence disables range support. 

If you can't trace the problematic configuration and/or not sure 
it's the case, you may start testing with a clean config.  E.g., 
with trivial configuration like this:

    http {
        include mime.types;

        server {
            listen 8080;

            location / {

A request to static mp4 file results in:

$ curl -I http://localhost:8080/mp4/test.mp4
HTTP/1.1 200 OK
Server: nginx/1.7.3
Date: Fri, 27 Jun 2014 18:38:24 GMT
Content-Type: video/mp4
Content-Length: 7147296
Last-Modified: Fri, 15 Jun 2012 15:50:37 GMT
Connection: keep-alive
ETag: "4fdb59cd-6d0f20"
Accept-Ranges: bytes

Maxim Dounin

More information about the nginx mailing list