difficulty adding headers

Maxim Dounin mdounin at mdounin.ru
Fri Jun 27 16:49:09 UTC 2014


Hello!

On Fri, Jun 27, 2014 at 11:50:47AM -0400, ura wrote:

> i need to ensure the Accept-Ranges header is present to serve video files
> while supporting forward/backwards seeking.
> i notice in many tutorials for nginx that this header is shown as being
> present in server response headers by default, yet not on my present setup.
> 
> i have used the following to add the header manually in the relevant places,
> yet so far have not been successful:

You shouldn't try to add Accept-Ranges header manually.  It will 
be added automatically when nginx supports range requests to the 
resource in question.

> 	# streamable mp4
> 	location ~* \.(mp4|mp4a)$ 
> 	#location ~* \.mp4$ 
> 	#location ^~ /file/download/ 
> 	{
> 		mp4;

Range requests to responses of mp4 module are supported starting 
at 1.5.13 (previously, range requests was supported only for files 
returned without modifications).  

If it doesn't work for you, it's probably time to upgrade.

[...]

> 		# tell nginx that final HTTP Status Code should be 206 not 200
> 		return 206;

This is just wrong, as it prevents nginx from returning a 
requested resource and unconditionally returns 206 response with 
an empty response body.

Again, you shouldn't try to return 206 manually.  The 206 response 
code is set automatically when a requested range is returned 
(instead of the full response).

-- 
Maxim Dounin
http://nginx.org/



More information about the nginx mailing list