Firefox Intermittent 502 Errors

May I suggest looking at the below articles:

https://support.cloudflare.com/hc/en-us/articles/115003011431-Troubleshooting-Cloudflare-5XX-errors#502504error

Have you checked if you block any Cloudflare connections to your origin host / server?
Like if you have some Firewall or?
In this case, kindly follow the instructions from the below article to allowlist and allow Cloudflare to connect to your origin host / server if so:
https://support.cloudflare.com/hc/en-us/articles/201897700-Allowing-Cloudflare-IP-addresses

Cloudflare IP addresses list can be found here: