difficulty adding headers

ura nginx-forum at nginx.us
Fri Jun 27 15:50:47 UTC 2014


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:

	# streamable mp4
	location ~* \.(mp4|mp4a)$ 
	#location ~* \.mp4$ 
	#location ^~ /file/download/ 
	{
		mp4;
		mp4_buffer_size 4M;
		mp4_max_buffer_size 20M;
		gzip off;
		gzip_static off;
		limit_rate_after 10m;
		limit_rate 1m;
		# here you add response header "Content-Disposition"
		# with value of "filename=" + name of file (in variable $request_uri),
		# so for url example.com/static/audio/blahblah.mp3 
		# it will be /static/audio/blahblah.mp3
		# ----
		#set $sent_http_content_disposition filename=$request_uri;
		    # or
		#add_header "content_disposition" "filename=$request_uri";

		# here you add header "Accept-Ranges"
		#set $sent_http_accept_ranges bytes;
 more_set_headers 'Accept-Ranges: bytes';
	#	add_header "Accept-Ranges" "bytes";
		add_header "Cache-Control" "private";
		add_header "Pragma" "private";
		# tell nginx that final HTTP Status Code should be 206 not 200
		return 206;
	}

as you can see, i have played with various options, yet none have succeeded.
i am not even sure that any of these directives are being called at all.
(this is part of a large-ish config file for a social network with many
features).

i am aware that nginx ignores add_header directives except for the ones in
the final location block for the presently served file.. yet so far this
awareness has not yielded a solution.

i am also not seeing a return code of 206 - instead the usual 200 is
returned when i access an mp4 file directly via curl.

anyone know what i am missing? thanks

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,251236,251236#msg-251236



More information about the nginx mailing list