【发布时间】:2014-01-14 18:41:07
【问题描述】:
我目前正在使用 Nginx 通过 HTTP 将我的 Mp4 文件提供给客户端。 我的大多数客户都在使用 XBMC 观看视频。其中一些报告错误:他们无法打开文件。 在我这边,我没有看到任何错误。每次访问都被授权(200),但我可以在我的日志中看到一个模式。当客户可以访问视频时,我只看到 2 行这样的:
123.456.789.123 - - [12/Jan/2014:01:19:34 -0500] "HEAD /myvideo.mp4?key=abc123456789 HTTP/1.1" 200 0 "-" "XBMC/11.0 Git:20120321-14feb09 (Windows NT 6.1;WOW64;Win64;x64; http://www.xbmc.org)"
123.456.789.123 - - [12/Jan/2014:01:20:05 -0500] "GET /myvideo.mp4?key=abc123456789 HTTP/1.1" 200 5964015 "-" "XBMC/11.0 Git:20120321-14feb09 (Windows NT 6.1;WOW64;Win64;x64; http://www.xbmc.org)"
并在错误日志中
2014/01/12 01:20:05 [info] 8661#0: *24936 writev() failed (104: Connection reset by peer) while sending mp4 to client, client: 123.456.789.123, server: cdn.domain.com, request: "GET /myvideo.mp4?key=abc123456789 HTTP/1.1"
当它起作用时:
123.456.789.123 - - [13/Jan/2014:12:01:48 -0500] "HEAD /myvideo.mp4?key=abc123456789 HTTP/1.1" 200 0 "-" "XBMC/11.0 Git:20120331-ebfd899 (iOS; 11.0.0 AppleTV2,1, Version 5.1.1 (Build 9B206f); http://www.xbmc.org)"
123.456.789.123 - - [13/Jan/2014:12:36:52 -0500] "GET /myvideo.mp4?key=abc123456789 HTTP/1.1" 200 191334139 "-" "XBMC/11.0 Git:20120331-ebfd899 (iOS; 11.0.0 AppleTV2,1, Version 5.1.1 (Build 9B206f); http://www.xbmc.org)"
123.456.789.123 - - [13/Jan/2014:12:36:53 -0500] "GET /myvideo.mp4?key=abc123456789 HTTP/1.1" 206 1942936 "-" "XBMC/11.0 Git:20120331-ebfd899 (iOS; 11.0.0 AppleTV2,1, Version 5.1.1 (Build 9B206f); http://www.xbmc.org)"
123.456.789.123 - - [13/Jan/2014:12:36:54 -0500] "GET /myvideo.mp4?key=abc123456789 HTTP/1.1" 206 1638856 "-" "XBMC/11.0 Git:20120331-ebfd899 (iOS; 11.0.0 AppleTV2,1, Version 5.1.1 (Build 9B206f); http://www.xbmc.org)"
123.456.789.123 - - [13/Jan/2014:13:05:34 -0500] "GET /myvideo.mp4?key=abc123456789 HTTP/1.1" 206 147060048 "-" "XBMC/11.0 Git:20120331-ebfd899 (iOS; 11.0.0 AppleTV2,1, Version 5.1.1 (Build 9B206f); http://www.xbmc.org)"
在错误日志中
2014/01/13 12:36:52 [info] 8659#0: *39151 client prematurely closed connection while sending mp4 to client, client: 123.456.789.123, server: cdn.francovox.com, request: "GET /myvideo.mp4?key=abc123456789 HTTP/1.1", host: "cdn.domain.com"
2014/01/13 12:36:53 [info] 8661#0: *39182 client prematurely closed connection while sending mp4 to client, client: 123.456.789.123, server: cdn.francovox.com, request: "GET /myvideo.mp4?key=abc123456789 HTTP/1.1", host: "cdn.domain.com"
2014/01/13 12:36:54 [info] 8661#0: *39184 client prematurely closed connection while sending mp4 to client, client: 123.456.789.123, server: cdn.francovox.com, request: "GET /myvideo.mp4?key=abc123456789 HTTP/1.1", host: "cdn.domain.com"
大多数情况下,客户在观看超过 90 分钟的视频时会遇到问题。
这是我的配置:
worker_processes 4;
pid nginx.pid;
events {
worker_connections 19000;
}
worker_rlimit_nofile 20000;
http {
server {
listen 80;
server_name cdn.domain.com;
access_log /var/log/nginx/cdn.domain.com.access.log;
error_log /var/log/nginx/cdn.domain.com.error.log debug;
include mime.types;
default_type application/octet-stream;
client_body_buffer_size 128K;
sendfile_max_chunk 128k;
client_max_body_size 800m;
client_header_buffer_size 256k;
large_client_header_buffers 4 256k;
output_buffers 1 512k;
server_tokens off;
ignore_invalid_headers on;
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
keepalive_timeout 0;
reset_timedout_connection on;
proxy_max_temp_file_size 0;
location / {
root /my/directory/;
auth_request /auth;
mp4;
mp4_buffer_size 1m;
mp4_max_buffer_size 5m;
}
location = /auth {
proxy_pass http://api.domain.com/auth;
proxy_pass_request_body off;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Content-Length "";
proxy_set_header X-Original-URI $request_uri;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
你知道有什么问题吗?
谢谢
【问题讨论】: