9

我尝试使用 nginx (origin + edge) 设置至少 2 台服务器。都使用mp4 -module编译。来源包含我所有的 mp4 文件。Edge 配置了所有按预期工作的缓存内容(见下文),每个 mp4 文件请求第二次由边缘缓存提供服务,没有原始流量。

但我希望能够在文件中查找。该功能来自 mp4 模块。只需附加查询参数 "?start=120" 告诉 nginx 从时间戳 120sec 开始提供 mp4 内容。这适用于直接请求的来源。但是一旦我在 nginx 的缓存位置启用 mp4-module,请求将是 404。

nginx.conf @起源:

server {
  listen       80;
  server_name  localhost;
  root         /usr/share/nginx/www;
  location ~ \.mp4$ {
    mp4;
    expires max;
  }
}

nginx.conf @ 边缘:

proxy_cache_path /usr/share/nginx/cache levels=2:2 keys_zone=icdn_cache:10m inactive=7d max_size=2g;
proxy_temp_path /usr/share/nginx/temp;
proxy_ignore_headers X-Accel-Expires Cache-Control Set-Cookie;
log_format cache '[$time_local] Cache: $upstream_cache_status $upstream_addr $upstream_response_time $status $bytes_sent $proxy_add_x_forwarded_for $request_uri';
access_log /usr/local/nginx/logs/cache.log cache;

upstream origin {
  server <origin-domain>;
}
server {
  listen       80;
  server_name  localhost;

  location ~ \.mp4$ {
    mp4;
    proxy_cache icdn_cache;
    proxy_pass http://origin;
    proxy_cache_key $uri;
  }
}

我也试过:

location / {
  location ~ \.mp4$ { mp4; }
  proxy_cache icdn_cache;
  proxy_pass http://origin;
  proxy_cache_key $uri;
}

有没有办法让缓存的 mp4 文件与 mp4-module 的搜索功能一起工作?

4

2 回答 2

0

您必须使用proxy_store. proxy_cache将为每个?start=xxxx请求创建大量文件。

要让 mp4 模块在文件中查找,您需要完整的电影。proxy_store将在缓存服务器上创建一个镜像。

于 2012-05-23T15:29:16.390 回答
0

proxy_cache是代理模块的一部分。目前您不能将 nginx mp4 模块与代理一起使用,它仅适用于静态文件,仅此而已。

于 2014-02-11T19:53:35.053 回答