我尝试使用nginx(原始边缘)设置至少2台服务器.都是用mp4模块编译的.原点包含我所有的mp4文件. Edge配置了所有按预期工作的缓存内容(见下文),第二次每个mp4文件请求由没有原始流量的边缘缓存提供.
但我希望能够在文件中寻找.功能来自mp4模块.只需追加查询参数“?start = 120”即告诉nginx以时间戳120秒开始提供mp4内容.这适用于直接请求的原点.但是只要我在nginx的缓存位置启用mp4-module,请求就会是404.
nginx.conf @ origin:
server {
listen 80;
server_name localhost;
root /usr/share/nginx/www;
location ~ \.mp4${
mp4;
expires max;
}
}
nginx.conf @ edge:
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
我也尝试过:
location / {
location ~ \.mp4${ mp4; }
proxy_cache icdn_cache;
proxy_pass http://origin;
proxy_cache_key $uri;
}
有没有办法让缓存的mp4文件与mp4-module的搜索功能一起工作?
最佳答案
您必须使用proxy_store. proxy_cache将为每个?start = xxxx请求创建大量文件.
要让mp4模块在文件中搜索,您需要完整的电影. proxy_store将在缓存服务器上创建一个镜像.