difficulty adding headers

Maxim Dounin mdounin at mdounin.ru
Mon Jun 30 19:15:56 UTC 2014


Hello!

On Sat, Jun 28, 2014 at 11:25:30AM -0400, ura wrote:

> after more exploration, i see that files which are placed in the root of my
> site can be preloaded and seeked correctly when played via the video.js
> package or directly as a video element.
> however, the videos that are played via the php application that runs my
> site are stored outside of the root directory of the site and i suspect that
> this is the cause of them not being streamed. (i am using the elgg social
> framework (www.elgg.org)). when i request one of these files from it's
> extermal/absolute url via curl, the accept_ranges header is not present, yet
> the header IS present when i place the same file at the public root of the
> site manually and request the file via curl.
> 
> e.g. the site is at : /var/www/html/mysite/
> and the videos are at: /var/www/data/paths/
> 
> so the root directive for the server in the nginx config is
> /var/www/html/mysite/
> 
> what appears to be occurring is that the request for the mp4 file is being
> processed via php so is using the .php location in my nginx config instead
> of the .mp4 config... thus the mp4; directive is not being triggered for mp4
> files.
> when i place the mp4 directive inside the php location block i just get
> prompted to download a file whenever i navigate to a php page.

In no particular order:

1. For HTML5 video streaming to work, you don't need "mp4" 
directive in your nginx config.  It's only needed for flash-based 
pseudo streaming.  HTML5 video streaming will work fine without 
the mp4 module, using standard HTTP range requests.

2. If php is used to return a response, it's php code 
responsibility to return various headers, including Accept-Ranges, 
as well as byte-ranges support itself. 

3. It would be more or less trivial to serve static files with 
nginx regardless of their location in the filesystem hierarchy.  
There are "root" and "alias" directives which can be set at 
location{} level, see http://nginx.org/r/root and 
http://nginx.org/r/alias.

4. (Following you next message) X-Accel-Redirect can be used to 
effectiently return static files, see 
http://wiki.nginx.org/XSendfile for some links.

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



More information about the nginx mailing list