Uploads to my website stall if using cloudflare reverse proxy

I already talked to technical support at the datacenter and they have no answers.

I have a dedicated server on HiVelocity.com that hosts a social media site. I had no problems before, but recently when making a photo or video post on the site, the uploads will stall. If the file is small, it will stall a bit and then I am able to post, but if it is a larger file, it stalls and will not complete.

A 2mb mp4 upload will never complete.

If the Cloudflare reverse proxy is turned off, the website works normally and fast.

Here is a video showing the problem. I have to wait for about 2 min. and then it fails. If I immediately refresh after the fail, it shows a 520 error. Recording #18

Normally, as soon as the blue progress bar finishes, the file is uploaded and I can post.

See video of posting the same with Cloudflare reverse proxy off: Recording #19

This is a test site, not the production site.

Larger than 100MB?
How much time does the request need to upload it, less or more than 100 seconds?

Is your origin host / server configured via PHP (if you are using PHP web app?) to accept file uploads w/ other PHP settings, like for example as follows below:

upload_max_filesize = 32M
post_max_size = 64M
max_file_uploads = 20
max_input_vars = 6000
max_input_time = 1000
memory_limit = 256M
max_execution_time = 300

What does your Developer Console (F12) from your Web browser say? Any warnings or errors shown from like Ajax or JavaScript?

1 Like

Larger than 100MB?

No, the failure occurs with only a 3MB mp4

How much time does the request need to upload it, less or more than 100 seconds?

The 3MB mp4 will upload in about 2 seconds without the Cloudflare reverse proxy turned on. With the Reverse Proxy turned on, a 520 error is thrown in about 90 seconds.

Is your origin host / server configured via PHP (if you are using PHP web app?) to accept file uploads w/ other PHP settings, like for example as follows below:

My php.ini:

display_errors = Off
max_execution_time = 600
max_input_time = 600
max_input_vars = 2000
memory_limit = 512M
post_max_size = 140M
session.gc_maxlifetime = 1440
session.save_path = "/var/cpanel/php/sessions/ea-php74"
upload_max_filesize = 128M
zlib.output_compression = Off

What does your Developer Console (F12) from your Web browser say? Any warnings or errors shown from like Ajax or JavaScript?

Yes, see screenshot.

This is what causes the web application (php, javascript, css, mariadb) to drop down a general “something went wrong” error message.

From the provided screenshot, I see you do get Error 520 on the HTTP POST request.

May I ask have you already looked into the 520 error about suggestions?

Before moving to Cloudflare, was your Website working over HTTPS connection?

May I ask what SSL option have you got selected under the SSL/TLS tab at Cloudflare dashboard for your domain ( Flexible, Full, Full Strict … )?

Here is a way to re-check if you correctly setup the SSL for your domain with Cloudflare:

In case you do not have an SSL certificate, you can use Cloudflare SSL, if so, kindly make sure you follow the instructions as follows on the below article to setup an SSL certificate using Cloudflare Origin CA Certificate:

Last but not least, kindly have a look here for more information regarding correct SSL settings at the SSL/TLS tab on Cloudflare dashboard:

Furthermore, do not skip below step and kindly re-check if Cloudflare is allowed to connect to your origin host to as follows in the below article:

Nevertheless, Cloudflare IP addresses list can be found here:

I asked HiVelocity tech about it and they asked Cpanel about it and they both said they have no idea why it happens. I have not looked at these personally, since it worked before and it works fine with the reverse proxy turned off. I will look into these myself:

  • Headers exceeding 16 KB (typically due to too many cookies)
  • An empty response from the origin web server that lacks an HTTP status code or response body
  • Missing response headers or origin web server not returning proper HTTP error responses

Yes it works fine on SSL now with Cloudflare reverse proxy turned off or turned on. I have a SSL cert on the server too.

It’s set to FULL.

HiVelocity techs said we only needed to whitelist IPs in firewall, which I have always done. I double checked them against the CloudFlare IP list and they are all there. I will still look into this more.

File uploads are not completely blocked with reverse proxy on, only files over 2mb won’t upload. Files under 2mb upload OK, but they are delayed and are slow to finish, while without the reverse proxy, uploads under 2mb will fully upload in less than 2 seconds for me.

Thanks!

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.