Using a REST API with Cloudflare as sub-domain issues

Hi,

I am using cloudlfare for my endpoint and it appears to be limiting the requests / size of the response for some of the endpoint on my configured sub-domain, With the 502 error returned from time to time, making the REST-API calls unreliable.

I have configured the following already:

[WAF]

[Page Rules]

  • Browser Integrity Check (disabled)
  • Disable Performance (selected)

and have Bot Detection disabled and Always Online disabled.


Is there somehting I am missing to configfure to make the REST-API calls always return data, without 502 error ?

Also I should note REST-API requests called to the endpoint with (approx.) 250 KB are ok, with consistent uptime and no 520 errors.

But requests with a response body size of 5-10 MB do give the 520 from time to time (more often)

502 means your server reported a Bad Gateway error - it isn’t generated by Cloudflare.

Check your server’s error logs for the reason.

Sorry, I meant 520, can’t edit original post

I’ve experienced the same issue and there are few topics about seeing 520 for particular WordPress files which are either existing or doesn’t exist, or some plugin restricts access to it.

May I ask is that data on xmlrpc.php, wlwmanifest.xml, or under some URL which contains the /wp-json/ path? :thinking:

Just in case, related to the WordPress, I’d suggest you to whitelist your origin host / server / hosting IP address by navigating to the Security → WAF → Tools → IP Access Rules with the action “allow” for your Website and try again.

It knows to happen due to the WordPress using HTTP/1.0 and empty user-agent, therefore while executing WP-Cron or some other related JSON/REST API request via plugin.

In think I have encountered your past posts, and went through some sources, but still keep getting 520 - Unknonw Errors with my REST-API using Cloudflare.

I know its Cloudflare, as without it, its 100% cadence.

I am using a custom sub-domain for my API with Python Flask.


Is the IP Access Rule possible to do for sub-domain only ?

Beofre my above adjusted configuration in the first post, I was constantly getting 520, with the above configuration I mention it became much better, but still 520 here and there. I guess it’s some other configurations I am missing.

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