Setup nginx to video streaming

  • Posted May 7, 2014

I use nginx to stream video from server.

But i get error: net::ERR_CONTENT_LENGTH_MISMATCH in this case:

  1. load page (video tag in background download small part of video - 2-3 Mb)
  2. wait one-two minutes
  3. play video browser download some more content (about 3 Mb) and then raise an error if i do not wait video play without errors

how can i fix this error?


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

instal Nginx

Andrew SB, thanks for your help! <br>I solve my issue with this directive: <br>send_timeout 100m; <br>this keeps connection for 100 minutes when a client retrieves a video file.

Could you post a sample of header? <br> <br>This bug report in Chrome explains why the problem happens there but not with Firefox. Firefox simply ignores it when the Content-Length header reports something different than the actual length. <br> <br> <br> <br>How about setting “proxy_buffering off;” ? <br> <br>This question over on ServerFault might help point you in the right direction: <br> <br>

Additional information: <br>nginx vhost config: <br>server { <br> listen 80; <br> server_name; <br> root /var/www/site; <br> index off; <br> access_log /var/log/nginx/media.access.log; <br> error_log /var/log/nginx/media.error.log; <br> <br> fastcgi_hide_header Set-Cookie; <br> expires max; <br> add_header Cache-Control public; <br> <br> location /video/ { <br> mp4; <br> root /var/www/site; <br> } <br>} <br> <br>error log files clean, no errors <br> <br>in access log, only successful requests: <br>ip - - [08/May/2014:18:04:58 +0300] “GET /video/shifts/8-9.mp4 HTTP/1.1” 304 0 “” “Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.132 Safari/537.36” <br>ip - - [08/May/2014:18:05:58 +0300] “GET /video/more/cleverclover.mp4 HTTP/1.1” 206 822075 “” “Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.132 Safari/537.36” <br> <br> <br>i get errors only in google chrome and opera browsers, in ff, safari, ie - video working good. <br> <br>i try use amazon s3, videos from amazon servers works fine, no errors. i compare headers from server - headers from my server same as amazon servers. <br> <br>i try this options: <br>1. disable gzip <br>2. set <br> keepalive_timeout 1200s; <br>3. set <br> proxy_http_version 1.1; <br> proxy_set_header Connection “”; <br> <br>but it makes no difference

Hi Ivan, <br> <br>If you could provide a little more information, we could probably help you better. Is this just static html with a video tag or are you using some kind dynamic framework? Also could you check the contents of your Nginx error log, most likely located at: <br> <br><pre> <br>/var/log/nginx/error.log <br></pre> <br> <br>I think that will probably show the real problem. Chances are it is a permissions issue. Is the video file accessible to the user running Nginx?