I went for the strict mode. and it replaced the 521 with 520. though not as frequent. I notice if I purge the cache I’ll get a bunch of them for my image files then it will settle down and work.
Here’s another piece of the puzzle I just remembered. About 4 months back I experienced the same thing (running in flex mode btw). I had my server on a different ISP (not AWS) and it was working great. Then one day, the 521’s starting to hit all of a sudden. the firewall was open and there was no issues with that. After a week of trying I gave up and moved to an EC2 server on AWS and it worked great (new IP, New machine). I just blamed my ISP and thought nothing more of it.
Now it’s happened again, same thing. runs fine for months, then 521’s (generally on image files but also scripts and such fail). So now I am thinking, maybe CF is throttling me down a bit because I am on the free plan. It may be worth an experiment to upgrade to ‘paid’ to see if I get more love that way.
I am also considering deleting my CF domain completely and restarting, thinking maybe something is jammed up. I’m not in production so we can play around like this.