1

We have been fighting this for more than a week:

  1. When CloudFlare is OFF - downloadable products work fine
  2. When CloudFlare is ON - the download starts and reaches 100%, the speed drops down to 0 and the download gets corrupt with an "unknown network error" message

There is a Page rule set in CF which says not to cache files which are on domain.com/download* but that doesn't help. Even in CF "developer mode" the problem exists. Only when the cloud is paused and the server is accessed directly - things work fine.

The hosting provider suspected the reason was gzip encoding. So I made a simple test:

  1. Create a directory domain.com/download-test
  2. Add an .htaccess file to it with contents:

AddType binary/octet-stream .bin SetOutputFilter DEFLATE

  1. Generated a simple 10mb file in the directory:

dd if=/dev/urandom of=test.bin bs=1MB count=10
10+0 records in 10+0 records out 10000000 bytes (10 MB) copied, 1.45406 s, 6.9 MB/s

  1. Downloaded the file with Cloudflare = ON without any problem and I see content-encoding:gzip in the HTTP headers. So the problem is definitely not gzip.

The hosting provider says they can't do anything as everything works directly to their server. Fair enough.

CloudFlare says "create a subdomain and serve downloads from there". But this is not possible because A) The store frontend runs entirely on HTTPS and our SSL certificate is only for domain.com and www.domain.com B) Magento has no option for serving downlodable products from a subdomain.

Desperately looking for a fix.

NOTE: Our downloadable products are not uploaded but linked to an external host (in case that matters).

closed as off-topic by Shaughn, brentwpeterson, liyakat, Amit Bera, Dexter May 21 '15 at 5:48

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about third-party modules are generally off-topic because the scope of functionality and code are not available. For more information, see this meta post/answer." – Shaughn, brentwpeterson, liyakat, Amit Bera, Dexter
If this question can be reworded to fit the rules in the help center, please edit the question.

1

The solution:

If gzip is enabled in your php-fpm this causes PHP to always give compressed output regardless of .htaccess settings. So what happens is that Cloudflare receives this compressed output and interprets it wrongly, thinking the file is bigger than what is delivered and therefore the download never completes and at some point gets broken.

The solution is to keep gzip for php-fpm to off when using Cloudflare and everything flies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.