Search code examples
apachecloudflarelitespeedopenlitespeed

apache behind cloudflare proxy not serving the mp4 file with status code 206


The mp4 video file is hosted on Capnel's apache server behind the cloudflare proxy. the file is loading on non-apple devices browser but not loading on apple's safari and other browser.

The reason of not loading the file is Safari sending the range header with request and apache request result should 200 if behind proxy or 206 without proxy. Once got cached cloudflare will result 206 for the request.

HTTP servers hosting media files for iOS must support byte-range requests, which iOS uses to perform random access in media playback. (Byte-range support is also known as content-range or partial-range support.) Most, but not all, HTTP 1.1 servers already support byte-range requests.

If you are not sure whether your media server supports byte-range requests, you can open the Terminal application and use the curl command-line tool to download a short segment from a file on the server:

Example command: curl -I --range 0-99 http://example.com/test.mp4

The same file is loading if webserver is litespeed or openlitespeed behind the cloudflare proxy.

if i turn-off the cloudflare proxy, the video is loading perefectly with status code 206 on apache as well as litespeed/openlitespeed.

I have done following things but not worked with apache and working with litespeed:

  • disable mod_deflate in apache
  • Bypass cache for mp4 file

Please help if you have solution.

Thanks Laxman


Solution

  • issue has been resolved by adding below htaccess

    SetOutputFilter DEFLATE
    SetEnvIfNoCase Request_URI .(mp4|ogv|webm)$ no-gzip dont-vary