Error 520 in Cloudflare, but request never reaches our server

My application has a command to send task attachments, for that, each attachment is sent to a URL that returns a text/html with the file download URL.

So, if 10 attachments are sent in a task, it will call the same URL 10 times, but each time with a different JSON return.
Ex.:

https://example.com/task/sendfile/TASKID /* Return: https://example.com/download/file1 */
https://example.com/task/sendfile/TASKID /* Return: https://example.com/download/file2 */
https://example.com/task/sendfile/TASKID /* Return: https://example.com/download/file3 */
https://example.com/task/sendfile/TASKID /* Return: https://example.com/download/fileN */
https://example.com/task/sendfile/TASKID /* Return: https://example.com/download/fileN */
https://example.com/task/sendfile/TASKID /* Return: https://example.com/download/file10 */

It happens that some requests present Cloudflare error 520, with the following message:

Web server is returning an unknown error

There is an issue between Cloudflare’s cache and your origin web server. Cloudflare monitors for these errors and automatically investigates the cause. To help support the investigation, you can pull the corresponding error log from your web server and submit it our support team. Please include the Ray ID (which is at the bottom of this error page). Additional troubleshooting resources.

Cloudflare says my server returned an error message, but the problem is that this request never made it to my Apache server.
Checking the access.log log, I only see the requests that were successful. The ones that had an error do not appear, if they had been processed by the server they should appear, even if the return code was different from 200.
In error.log nothing appears either.

If the client sends between 1 and 3 files this type of problem does not occur.

In the error description it says the problem was between Cloudflare caching and my site.
Is Cloudflare caching the return and is this causing a problem?

There is a possibility that Cloudflare IPs are getting blocked by the firewall temporarily. You can try manually whitelisting all IPs of Cloudflare in the firewall. Or use the code of X-Forwarded-For which shows the real IP of the visitors.

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